Exporting data.frame as .csv with code.
write.csv(df, "name.csv")
LogitTV.Rda has 3000 rows and 4 columns.
My code has an error when identifying the data.frame.
load("~/Home Automation/LogitTV.Rda")
write.csv(LogitTV.Rda, "LogitTV.csv")
Error in is.data.frame(x) : object 'LogitTV.Rda' not found
Checked the following:
1) Cleaned the console of previous history
2) Working Directory set as ~/Home Automation/
Anything else to check for preventing the error?
Thanks
LogitTV.Rda
is, confusingly, not the name of the object that gets loaded.
Try:
loadedObj <- load("~/Home Automation/LogitTV.Rda")
write.csv(get(loadedObj), file="LogitTV.csv")
This assumes that the .Rda
file contains only a single R object, and that it is a data frame or matrix.
It would be nice if write.csv
had a way to accept the name of an object instead of the object itself (so get()
was unnecessary), but I don't know of one.
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.