Session Ready
Exercise

col_types, skip and n_max

Apart from controlling how columns are named, you can also specify which types the columns should be in your imported data frame. You can do this with col_types. If set to NULL, the default, functions from the readr package will try to find the correct types themselves. You can manually set the types with a string, where each character denotes the class of the column: character, double, integer and logical. _ skips the column as a whole.

Through skip and n_max you can also control which part of your flat file you're actually importing into R. Watch out: Once you skip some lines, you also skip the first line that can contain column names.

potatoes.txt, a flat file with tab-delimited records and the column names in the first line, is available in your workspace.

Instructions
100 XP
  • Finish the first read_tsv() call to import observations 7, 8, 9, 10 and 11 from potatoes.txt.
  • In the second read_tsv() call, edit the col_types argument to import all columns as characters (c). Store the resulting data frame in potatoes_char.