Learn R Programming

specmine (version 4.0.0)

read_csvs_folder: Read all CSV peak files in a folder

Description

Lists CSV files in a folder and reads them into a named list of data frames.

Usage

read_csvs_folder(foldername, verbose = TRUE, ...)

Value

A named list of data frames, one per CSV file found in the folder.

Arguments

foldername

Path to the folder containing CSV files.

verbose

Logical; whether progress messages should be shown.

...

Additional arguments passed to read.csv().

Examples

Run this code
folder <- file.path(tempdir(), "peak_csvs")
dir.create(folder, showWarnings = FALSE)
utils::write.csv(data.frame(ppm = c(1, 2), int = c(10, 20)),
                 file.path(folder, "sample1.csv"), row.names = FALSE)
utils::write.csv(data.frame(ppm = c(1, 3), int = c(15, 30)),
                 file.path(folder, "sample2.csv"), row.names = FALSE)
read_csvs_folder(folder, verbose = FALSE)

Run the code above in your browser using DataLab