Home > Enterprise >  How to import many dataframes from R into a one Excel file in a simple way?
How to import many dataframes from R into a one Excel file in a simple way?

Time:11-03

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.

CodePudding user response:

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

library(writexl)
write_xlsx(l2, 'file.xlsx')
  • Related