Learn R Programming

readr (version 0.1.1)

write_csv: Save a data frame to a csv file.

Description

This is about twice as fast as write.csv, and never writes row names. Non-atomic vectors are coerced to character vectors with as.character. All columns are encoded as UTF-8.

Usage

write_csv(x, path, append = FALSE, col_names = !append)

Arguments

x
A data frame to write to disk
path
Path to write to. If "" will return the csv file as a string.
append
If FALSE, will create a new file. If TRUE, will append to an existing file.
col_names
Write columns names at the top of the file?

Examples

Run this code
cat(write_csv(head(mtcars), ""))
cat(write_csv(head(iris), ""))

Run the code above in your browser using DataLab