Reads a single input file, dispatching on its extension. CSV is
read with utils::read.csv() (strings as character); RDS with
base::readRDS(). Unsupported extensions and unreadable files raise an
error that names the offending file.
Examples
path <- tempfile(fileext = ".csv")
write.csv(data.frame(x = 1:3), path, row.names = FALSE)
load_by_ext(path)
#> x
#> 1 1
#> 2 2
#> 3 3