Session Ready
Exercise

stringsAsFactors

You already learned by now how to use the header and sep arguments. You can also specify stringsAsFactors: it tells R whether it should convert strings in the flat file to factors.

For all importing functions in the utils package, this argument is TRUE, which means that you import strings as factors. This only makes sense if the strings you import represent categorical variables in R. If you set stringsAsFactors to FALSE, the data frame columns corresponding to string in your text file will be character.

You'll be working with the swimming_pools.csv file from before. The file has the column names in the first row and uses commas to separate values. It contains two columns (Name and Address), which shouldn't be factors.

Instructions
100 XP
  • Use read.csv() to import the data in "swimming_pools.csv" as a data frame called pools; make sure that strings are imported as characters, not as factors.
  • Using str(), display the structure of the dataset and check that you indeed get character vectors instead of factors.