The write.csv Function in R


The write.csv() is a built-in R function that writes data into a CSV file. It takes a data frame as data, a filepath as a file, and exports it to that file.

write.csv(x, file, traitsAsDir = FALSE, csv2 = TRUE, row.names = FALSE, fileEncoding = "UTF-8" ...)

x: It is a data frame or other R data added to the csv.

Below is an example in Windows.

write.csv(df, file = "C:\\R_Projects\\myProject.csv")

You can read more about this function at Data to Fish in an article called How to Export Data Frame to CSV in R.

Leave a Reply