Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export R data to csv

I've read a .csv file into R, ran some code to edit it and now want to export this data frame as .csv, to read it in later again or whatsoever. How can I accomplish this in "clean code"?

like image 376
user13608970 Avatar asked Dec 17 '25 23:12

user13608970


2 Answers

write.csv(dataframe,"~/Downloads/filename.csv", row.names = FALSE)

Different computers use different directions for slashes (\or/)and on a mac, I typically have to do the "~/ " at the beginning for windows it is typically "C:"

like image 71
Julia Avatar answered Dec 19 '25 11:12

Julia


Assuming your data is called df

write.csv(df, "specify_path_and_file_name.csv")
like image 41
Dominik S. Meier Avatar answered Dec 19 '25 11:12

Dominik S. Meier