简体   繁体   中英

How to export a large dataset from R to CSV?

I have a R data frame with 20,000 observations and 2100 variables, how do I export it to CSV format. I used write.table as follows

write.table(a,"Lucas1",sep=",",row.names=FALSE);

where a is the dataset. Lucas1 is the name of the file in which I want to store the data. I got following error

Error in if (inherits(X[[j]], "data.frame") && ncol(xj) > 1L) X[[j]] <- as.matrix(X[[j]]) : 
missing value where TRUE/FALSE needed

I am a beginner in R, can anyone suggest me an easy solution to this problem?

You might want to look at write_csv in the new readr package. I would imagine it would be quicker than utils::write.csv . As an added bonus, you no longer need to specify row.names = FALSE

write_csv(a, "Lucas1.csv")

我们可以用

write.csv(a, "Lucas1.csv", quote=FALSE, row.names=FALSE)

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