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 to import many dataframes from R into a one Excel file in a simple way?

I have this dataset (let’s imagine it with 900 variables )

df = data.frame(x = c(1,0,0,0,1,1,1), y = c(2,2,2,2,3,3,2) )

l1 = lapply(df,table)

l2 = lapply(l1,as.data.frame)

I created a list of dataframes that I wish to be extracted to a one file excel in a simple way using lapply or something like this. Appreciate the help.

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 :

write_xlsx() from writexl saves each list item in one sheet of an Excel file:

library(writexl)
write_xlsx(l2, '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