import_list: Import list of data frames

View source: R/import_list.R

import_listR Documentation

Import list of data frames


Use import() to import a list of data frames from a vector of file names or from a multi-object file (Excel workbook, .Rdata file, zipped directory in a zip file, or HTML file)


  setclass = getOption("rio.import.class", "data.frame"),
  rbind = FALSE,
  rbind_label = "_file",
  rbind_fill = TRUE,



A character string containing a single file name for a multi-object file (e.g., Excel workbook, zip file, or HTML file), or a vector of file paths for multiple files to be imported.


An optional character vector specifying one or more classes to set on the import. By default, the return object is always a “data.frame”. Allowed values include “tbl_df”, “tbl”, or “tibble” (if using tibble), “arrow”, “arrow_table” (if using arrow table; the suggested package arrow must be installed) or “data.table” (if using data.table). Other values are ignored, such that a data.frame is returned. The parameter takes precedents over parameters in ... which set a different class.


If file is a single file path, this specifies which objects should be extracted (passed to import()'s which argument). Ignored otherwise.


A logical indicating whether to pass the import list of data frames through data.table::rbindlist().


If rbind = TRUE, a character string specifying the name of a column to add to the data frame indicating its source file.


If rbind = TRUE, a logical indicating whether to set the fill = TRUE (and fill missing columns with NA).


Additional arguments passed to import(). Behavior may be unexpected if files are of different formats.


If rbind=FALSE (the default), a list of a data frames. Otherwise, that list is passed to data.table::rbindlist() with fill = TRUE and returns a data frame object of class set by the setclass argument; if this operation fails, the list is returned.

See Also

import(), export_list(), export()


## For demo, a temp. file path is created with the file extension .xlsx
xlsx_file <- tempfile(fileext = ".xlsx")
        mtcars1 = mtcars[1:10, ],
        mtcars2 = mtcars[11:20, ],
        mtcars3 = mtcars[21:32, ]

# import a single file from multi-object workbook
import(xlsx_file, sheet = "mtcars1")
# import all worksheets, the return value is a list

# import and rbind all worksheets, the return valye is a data frame
import_list(xlsx_file, rbind = TRUE)

rio documentation built on Sept. 19, 2023, 5:06 p.m.