So, with a bit of digging, we were able to fix that problem. Of course, it would have been nice to know in advance that some parts of the city use letters in their address numbers! But now that we know that, we can use another function to manually set column types.
To do this, we add the
col_types argument to the
col_types works with the other read functions as well.
Suppose we know that the ages in the
students data should be of an integer data type. When reading the file into memory, we'd write:
students <- read_csv("winters_students.csv",
col_types = cols(age = col_integer()))
Pay attention to the construction of this option. The
cols() function has as its argument the name of the column we would like to change. The columns we don't want to change don't have to be mentioned. Next, we have
col_integer(). This specifies the type of data in this column. There are other options that work with
cols; we could also write
col_double() for those data types.