简体   繁体   中英

Export .RData into a CSV in R

I want to export fake.bc.Rdata in package "qtl" into a CSV, and when running "summary" it shows this is an object of class "cross", which makes me fail to convert it. And I tried to use resave, but there is warning:cannot coerce class 'c("bc", "cross")' to a data.frame.

Thank you all for your help in advance!

CSV stands for comma-separated values, and is not suitable for all kinds of data. It requires, like indicated in the comments, clear columns and rows.

Take this JSON as an example:

{ 
"name":"John",
 "age":30,
 "likes":"Walking","Running"
}

If you were to represent this in CSV-format, how would you deal with the difference in length? One way would be to have repeated data

name,age,likes
John,30,Walking
John,30,Running

But that doesn't really look right. Even if you merge the two into one you would still have trouble reading the data back, eg

name,age,likes
John,30,Walking/Running

Thus, CSV is best suited for tidy data .

TL;DR

Can your data be represented tidily as comma-separated values, or should you be looking at alternative forms of exporting your data?

EDIT:

It appears you do have some options: If you look at the reference , you have the option to export your data using write.cross() .

For your data, you could use write.cross(fake.bc, "csv", "myCrossData", c(1,5,13)) . It then does the following:

Comma-delimited formats: a single csv file is created in the formats "csv" or "csvr". Two files are created (one for the genotype data and one for the phenotype data) for the formats "csvs" and "csvsr"; if filestem="file", the two files will be names "file_gen.csv" and "file_phe.csv".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM