Home Forums Analytics / Predictive Analytics Factors variables reading in as characters Reply To: Factors variables reading in as characters

#3218
SamCastillo
Participant

    Hi again Porkins,

    Good questions.  You can get practice with these questions by enrolling in our online course – there are 9 practice exams and more than 135 practice questions.  Review your work quickly by watching video solutions.  This method has helped hundreds of actuaries to successfully pass.  This is the fastest way to study for this exam.

    It’s great to be asking these questions now while there is still plenty of time to prepare.

    “…it reads the factor variables in as character strings.  … why would I have to do that?”

    This is a good programming question but is more info that you need to know for exam PA.  Characters are preferred when loading the data because there are only a finite number of factor levels possible whereas characters can have an unlimited number.  Otherwise there will be import errors.  The “tidyverse” library uses an improved version of the base R “data.frame” that removed the “stringAsFactors” argument.  All data should be imported as characters and then converted to factors after looking at the data dictionary.

    “Does this happen in the real exam?”

    Yes.  You will need to convert to factors manually.  Numeric variables also may be factors.  For example, I’m working on the solution to the December 7th 2020 exam that uses Bike Sharing, and the first question is exactly this: decide on which variables to convert to factors.

    “Is this just the version of RStudio”

    Good thought to check the software version.  This is a different thing entirely.  Rstudio is just the IDE and this is related to the R language itself (the engine under the hood of the IDE).  I just updated to RStudio v 1.4.1 this morning because I was getting an error where it would crash when calling the “library” function, so that’s always the first thing to check.

    Does this answer your questions?

    Best regards,

    Sam Castillo

    Course Instructor at ExamPA.net