Learn R Programming

qPRAentry (version 0.1.0)

load_csv: 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"))

Value

A data frame containing the data from the CSV file.

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.

Examples

Run this code
# 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

Run the code above in your browser using DataLab