I was wondering whether there is a way to use readr::read_csv() to read a csv file, but only read select columns - by index. For example, can I read in the first 3 columns , or the 2nd, 5th, and 9th columns (where I do not necessarily know the column names in advance)?
You can do it by passing a string of the standard type abbreviations to the col_types() parameter.
Use _ or - to skip columns you don't want. You can manually specify the type of each column that you want to read or use ? to allow the parser to guess.