- Use the
read_csv function to read each of the files that the following code saves in the files object:
path <- system.file("extdata", package = "dslabs")
files <- list.files(path)
files
- Note that the last one, the
olive file, gives us a warning. This is because the first line of the file is missing the header for the first column.
Read the help file for read_csv to figure out how to read in the file without reading this header. If you skip the header, you should not get this warning. Save the result to an object called dat .
- A problem with the previous approach is that we don’t know what the columns represent. Type:
names(dat)
to see that the names are not informative.
Use the readLines function to read in just the first line (we later learn how to extract values from the output).