Reads CSV, Excel (.xlsx, .xls), SAS (.sas7bdat), and XPT (.xpt)
files into a tibble. Dispatches on file extension.
Arguments
- file
Path to the data file.
- sheet
For Excel files, the sheet name or index to read. Passed to
readxl::read_excel(). Ignored for non-Excel formats.- encoding
Character encoding for CSV files (e.g.
"UTF-8","latin1"). Passed asreadr::locale(encoding = encoding). Ignored when reading non-CSV formats or when the caller already supplies alocaleargument in....- ...
Additional arguments passed to the underlying reader (
readr::read_csv(),readxl::read_excel(),haven::read_sas(), orhaven::read_xpt()).
Value
A tibble::tibble(). SAS/XPT imports preserve haven_labelled
vectors as-is.
Examples
f <- system.file("extdata", package = "dataganger")
# read_input(file.path(f, "example.csv"))
# read_input(file.path(f, "example.csv"), encoding = "latin1")
