Write List to CSV File
write_list.Rd
Write 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
x
argument.- append
logical. Only relevant if
file
is 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/t5/14gs56bj7djcylkj26c908n40000gn/T//Rtmp9xWhGD/file1c9c323b1978.csv'
# with a data frame in list
tmp$mtcars <- head(mtcars, 10)
write_list(tmp, file = tempfile(fileext = ".csv"))
#> ✓ Writing 'tmp' to: '/var/folders/t5/14gs56bj7djcylkj26c908n40000gn/T//Rtmp9xWhGD/file1c9c46052f0b.csv'