Output from the str(df) function

The str() function is an important function to run after you create a new data object. If you examine the output from the str(df) function in the log, you will see that the default read.csv function you have just run has defined each of the variables in the data as either numeric or factor. While at this point it is okay to leave it as is, we will eventually want to change the data type for these variables since Length.of.Stay is not a factor, it is an integer. Alternatively, we can perform another read.csv function that specifies the exact data type that we want, specifying the ColClasses vector. I usually like to look at a small dataset sample first, then determine what the data type should be, and then ...

Get Practical Predictive Analytics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.