PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 18, 2022

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

 August 18, 2022     csv, export-to-excel, list, output, r     No comments   

Issue

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)


Answered By - Ben Toh
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing