load_csv | R Documentation |
A wrapper for readr::read_csv that uses alrtools::repair_header to fix the header, but keeps a copy of the original values in an attribute.
load_csv(
path,
col_types = NULL,
na = c("", "NA", "#N/A", "#DIV/0!", "#NAME?", "#REF!", "#VALUE!", "#NULL!"),
...
)
path |
path to the CSV file to load |
col_types |
One of NULL, a cols() specification, or a string. See vignette("readr") for more details. |
na |
values to replace with NA – defaults to Excel errors |
... |
other arguments passed to readr::read_csv |
Returns a tibble of the CSV file
my_data <- data.frame(
'Seq No' = 1:26,
'Uppercase Letters' = LETTERS,
'Lowercase Letters' = letters,
check.names = FALSE)
temp_path <- tempfile(fileext = '.csv')
write.csv(x = my_data, file = temp_path, row.names = FALSE)
my_data_reloaded <- load_csv(temp_path)
# Fixed Names
names(my_data_reloaded)
# Original Names
attr(my_data_reloaded, 'original_header')
# Clean Up
unlink(temp_path)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.