read.data | R Documentation |
Reads multiple data files from a specified directory and combines them into a single data frame. The function supports parallel processing for improved performance with large datasets.
read.data(directory, lookfor = ".txt", .parallel = F)
directory |
Character string specifying the path to the directory containing the data files |
lookfor |
Character string specifying the file extension or pattern to match (default = ".txt") |
.parallel |
Logical value indicating whether to use parallel processing (default = FALSE) |
The function: * Changes the working directory to the specified location * Finds all files matching the specified pattern * Reads each file as a data table with headers * Combines all data tables into a single data frame * Supports parallel processing via parLapply when .parallel = TRUE
A data frame containing the combined data from all matching files
When using parallel processing, make sure to have a cluster object 'cl' initialized beforehand.
# Read all .txt files from a directory
data <- read.data("path/to/files", lookfor = ".txt")
# Read all .csv files using parallel processing
data <- read.data("path/to/files", lookfor = ".csv", .parallel = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.