View source: R/bcat_import_data.R
| bcat_import_data | R Documentation |
Utility to import multiple data sets from a directory into a named list.
bcat_import_data(location, extension, import_function, recursive = TRUE)
location |
Character. Directory from which to import data. |
extension |
Character. File extension to match (without "."). |
import_function |
Function used to read each file (e.g., |
recursive |
Logical. Search subdirectories? Default is |
A named list of imported objects. Names are derived from filenames
without their extensions, and each element contains the result returned by
import_function() for one matching file.
Saannidhya Rawat
Other utilities:
bcat_extract_metadata(),
bcat_new_quarto(),
bcat_setup_rmd(),
bcat_source_rmd()
tmp_dir <- tempfile("rbearcat-data-")
dir.create(tmp_dir)
csv_path <- file.path(tmp_dir, "example.csv")
utils::write.csv(data.frame(x = 1:3, y = letters[1:3]), csv_path, row.names = FALSE)
datasets <- bcat_import_data(tmp_dir, "csv", utils::read.csv)
names(datasets)
datasets$example
unlink(tmp_dir, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.