load_csv: Load a CSV file with automatic separator detection

View source: R/load_csv.R

load_csvR Documentation

Load a CSV file with automatic separator detection

Description

Reads CSV files containing more than one column of data. It automatically detects common separators (i.e., comma, semicolon, tab), while allowing users to specify encoding and decimal separators as required.

Usage

load_csv(filepath, dec = ".", encoding = getOption("encoding"))

Arguments

filepath

A string specifying the path to the CSV file (.csv extension).

dec

A character specifying the decimal separator to use. Default is "." (period).

encoding

A string specifying the encoding of the file. Default is the native system encoding set by getOption("encoding"). For more details on encoding see file.

Value

A data frame containing the data from the CSV file.

Examples

# file path
fpath <- system.file("extdata", "data_ex.csv", package="qPRAentry")
# Load a CSV file
df <- load_csv(fpath) 
head(df) # value as character
# Load a CSV file with comma separated decimals
df <- load_csv(fpath, dec = ",") # value as numeric


qPRAentry documentation built on April 12, 2025, 1:12 a.m.