Read input from a directory from different possible formats
read_input.Rd
Read input from a directory from different possible formats
Usage
read_input(path_input, type_input = c("csv2", "csv1", "ods", "xlsx"))
Details
read_input()
loads all data from a given type in a directory. It does not
perform any check on the integrity of the data.
type_input
controls the way data is imported:
- csv2
use data.table::fread with dec = "," on all "csv" files found in path_input. So sep is guessed.
- csv1
use data.table::fread without sepcification on all "csv" files found in path_input.. So sep is guessed.
- ods
use readODS::read_ods on all sheets of the "ods" file found in path_input.
- xlsx
use readxl::read_xlsx on all sheets of the "xlsx" file found in path_input.
Author
Frédéric Grelot, frederic.grelot.1994_cran@m4x.org
Examples
path_input = system.file("extdata", "test", package = "floodam.cba.sa")
# Default to csv2
input_default = read_input(path_input)
input_csv2 = read_input(path_input, "csv2")
identical(input_default, input_csv2)
#> [1] TRUE
# ods format
input_ods = read_input(path_input, "ods")
# May not be TRUE because of numeric / integer format
identical(input_default, input_ods)
#> [1] FALSE
all.equal(input_default, input_ods, check.attributes = FALSE)
#> [1] TRUE
# xlsx format
input_xlsx = read_input(path_input, "xlsx")
# May not be TRUE because of numeric / integer format
identical(input_default, input_xlsx)
#> [1] FALSE
all.equal(input_default, input_xlsx, check.attributes = FALSE)
#> [1] TRUE