exporting created csv in r

You can export a data frame as a csv file in R using the write.csv() function. Here is an example:

Assuming you have a data.frame called my_data that you want to export to CSV:

main.r
write.csv(my_data, "path/to/my_data.csv", row.names = FALSE)
61 chars
2 lines

This will write my_data to a CSV file located at "path/to/my_data.csv". The row.names = FALSE argument ensures that row numbers are not included in the exported file.

If you want to export a data frame as a TSV (tab-separated values) instead of a CSV, then you can use the write.table() function with the sep = "\t" argument:

main.r
write.table(my_data, "path/to/my_data.tsv", sep = "\t", row.names = FALSE)
75 chars
2 lines

Note that you should replace "path/to/my_data.csv" or "path/to/my_data.tsv" with the actual file path where you want to save the exported file.

related categories

gistlibby LogSnag