By default, most of the data import functions in R will attempt to guess the data type for each column at the import phase. This is usually nice, because it saves us from tedious work. However, it can backfire when there are, for example, stray punctuation marks in what are supposed to be numeric columns. To verify this, we can use the assert function with the is.numeric base function, as shown in the following code:
iris <- assert(iris, is.numeric, -Species)
We can use the is.character and is.logical functions with assert, too.
An alternative method that will disallow the import of unexpected data types is to specify the data type that each column should have at the data import phase, with the colClasses ...