read.data: Read Multiple Data Files from a Directory

View source: R/read.data.r

read.dataR Documentation

Read Multiple Data Files from a Directory

Description

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.

Usage

read.data(directory, lookfor = ".txt", .parallel = F)

Arguments

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)

Details

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

Value

A data frame containing the combined data from all matching files

Note

When using parallel processing, make sure to have a cluster object 'cl' initialized beforehand.

Examples

# 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)


ccamp83/mu documentation built on Nov. 7, 2024, 5:17 p.m.