To export a dataframe as a csv file in R, you can use the write.csv()
function. Here's an example:
main.r224 chars10 lines
In this example, we create a dataframe df
with three columns (name
, age
, and city
), and three rows of data. Then, we use the write.csv()
function to export this dataframe as a csv file named my_dataframe.csv
.
Note that the csv file will be saved in your current working directory (you can check your current working directory using the getwd()
function). If you want to specify a different directory or file path for the saved csv file, you can include that as the second argument to write.csv()
.
gistlibby LogSnag