rexceldataframe

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.


Solution

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

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