rio (version 0.5.26)

export_list: Export list of data frames to files

Description

Use export to export a list of data frames to a vector of file names or a filename pattern.

Usage

export_list(x, file, ...)

Arguments

x

A list of data frames to be written to files.

file

A character vector string containing a single file name with a %s wildcard placeholder, or a vector of file paths for multiple files to be imported. If x elements are named, these will be used in place of %s, otherwise numbers will be used; all elements must be named for names to be used.

Additional arguments passed to export.

Value

The name(s) of the output file(s) as a character vector (invisibly).

Details

export can export a list of data frames to a single multi-dataset file (e.g., an Rdata or Excel .xlsx file). Use export_list to export such a list to multiple files.

See Also

import, import_list, export

Examples

Run this code
# NOT RUN {
library('datasets')
export(list(mtcars1 = mtcars[1:10,], 
            mtcars2 = mtcars[11:20,],
            mtcars3 = mtcars[21:32,]), "mtcars.xlsx")

# import all worksheets
mylist <- import_list("mtcars.xlsx")

# re-export as separate named files
export_list(mylist, file = paste0("mtcars", 1:3, ".csv"))

# re-export as separate files using a name pattern
export_list(mylist, file = "%s.csv")

# cleanup
unlink("mtcars.xlsx")
unlink("mtcars1.csv")
unlink("mtcars2.csv")
unlink("mtcars3.csv")

# }

Run the code above in your browser using DataCamp Workspace