Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i write systematic data into excel sheet with systematicly?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading