Write List to CSV File
write_list.RdWrite a list of data frames of vectors (or a mixture
of both) to a single *.csv file.
Arguments
- x
A list to be written to file, typically a list of data frames.
- file
either a character string naming a file or a connection open for writing.
""indicates output to the console.- rn_title
A title for the row names column (for data frames). Must match the length of the
xargument.- append
logical. Only relevant if
fileis a character string. IfTRUE, the output is appended to the file. IfFALSE, any existing file of the name is destroyed.- ...
Additional arguments passed to
write.table().
Examples
tmp <- lapply(LETTERS[1:5], function(x) rnorm(10, mean = 10, sd = 3))
names(tmp) <- LETTERS[1:5]
write_list(tmp, file = tempfile(fileext = ".csv"))
#> ✓ Writing 'tmp' to: '/var/folders/0w/4z5l9vds32nbkz7l22n8j6s80000gn/T//Rtmp0DjqlJ/file116daf523c0.csv'
# with a data frame in list
tmp$mtcars <- head(mtcars, 10)
write_list(tmp, file = tempfile(fileext = ".csv"))
#> ✓ Writing 'tmp' to: '/var/folders/0w/4z5l9vds32nbkz7l22n8j6s80000gn/T//Rtmp0DjqlJ/file116d63fe17de.csv'