I have been working with big though systematic data. Therefore I have wrote only shape of my data frame to below. I need to write every 3 column into different excel sheet. I tried some code and functions but i didnt achieve due to my lack of programming.
x1 <- c(2,3,8,9)
x2 <- c(4,6,2,1)
x3 <- c(1,2,25,20)
y1 <- c(45,15,56,74)
y2 <- c(56,25,4,9)
y3 <- c(92,52,4,9)
z1 <- c(71,45,61,96)
z2 <- c(31,4,78,7)
z3 <- c(12,22,11,31)
df<-data.frame(x1,x2,x3,y1,y2,y3,z1,z2,z3)
df
x1 x2 x3 y1 y2 y3 z1 z2 z3
1 2 4 1 45 56 92 71 31 12
2 3 6 2 15 25 52 45 4 22
3 8 2 25 56 4 4 61 78 11
4 9 1 20 74 9 9 96 7 31
Thanks for helps.
CodePudding user response:
We could split by the names and then write to different files
lst1 <- split.default(df, sub("\\d ", "", names(df)))
library(openxlsx)
write.xlsx(lst1, file = "file.xlsx")