June 2017
Beginner to intermediate
576 pages
15h 22m
English
If you run an str() function on the variables in the dataframe, you will see that all of them are of type chr (character). We also saw that in the import file dialog:
str(df)

We will want some of these variables to be integers, so we can use the cast() function to change some of them. Also, clean up some of the leading and trailing spaces using the trim() function:
df$age <- cast(trim(df$age),'integer') df$perstop <- cast(df$perstop,'integer') df$perobs <- cast(df$perobs,'integer') df$ser_num <- cast(df$ser_num,'integer') df$datestop <- cast(df$datestop,'integer') df$timestop <- cast(df$timestop,'integer') ...