fread_csv: Reads CSV files checking for factors

Description Usage Arguments Value Examples

Description

Wrapped around base read.csv, fread_csv checks the number of levels of a factor when reading csv files. If the lenght of the levels is the same as the length of the variable, it will convert the variable to a character type. Otherwise it will leave it as a factor.

Usage

1
fread_csv(file, check.factor = TRUE, ...)

Arguments

file

File to be uploaded

check.factor

If check.factor = TRUE, then the function will check for the length of factor levels.

...

Name-value pairs of summary functions like read.csv()

Value

A data frame containing a representation of the data in the file

Examples

1
2
3
4
5
6
7
8
9
test1 <- factor(letters[1:10])
tf <- tempfile()
write.csv(test1, tf)

charreading <- fread_csv(tf, check.factor = TRUE)
str(charreading)

facreading <- fread_csv(tf, check.factor = FALSE)
str(facreading)

lmguzman/MelissaFactors documentation built on May 21, 2019, 7:35 a.m.