Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Reading from a file
7. Converting factors – the stringsAsFactors option
Reading from an Excel file
Summary

Instruction

As you see, all strings in this report are stored as factors. R automatically does this when reading a file into memory. Sometimes we want strings as factors, but not here. This would make every employee name a level of the variable first_name or last_name. We can fix this by adding another option to the read command: stringsAsFactors. It looks like this:

report_thunderrock <- read.table(
  "data/thunderrock_industries.csv",
  sep = ";",
  header = TRUE,
  stringsAsFactors = FALSE)

Exercise

Amend the template code, so it won't read in strings as factors.