Search code examples
rlistcsvoutputexport-to-excel

How to save an R list as csv or Excel file?


R numerical list

I wonder how to export the list above to csv or excel? I do not need to keep the data type, but having counts displayed next to Embase.n in a csv/Excel file would be very useful to me. Many thanks for helping me out.


Solution

  • From what I see, your list seems to consist of one single value for each element. You can use Jonathan V. Solórzano's way to get a very wide table. Alternatively you can use unlist() to collapse your list into a vector, and create a dataframe and export it.

    mylist <- list(Embase.1 = 1, Embase.2 = 0, Embase.3 = 2)
    v <- unlist(mylist)
    df <- data.frame(Embase = v)
    df
    #         Embase
    #Embase.1      1
    #Embase.2      0
    #Embase.3      2
    write.csv(df, row.names = F)