Factors Flashcards
1
Q
Factors
A
- Variables in R which take on a limited number of different values = known as “categorical” variables.
- Enter into statistical models differently than numerical variaables.
2
Q
How Factors are stored in R
A
- Stored as a vector of integer values with corresponding set of character values = the character values are displayed.
- An efficient way to store character values.
3
Q
factor()
A
- Function that creates factors.
- Automatically designates variables as factors during import.
- Numeric + character variables can be converted into factors.
- Factor’s levels will always be displayed as character values.
4
Q
stringsAsFactors =
A
- An option whose default is set equal to TRUE.
- Turns all the variables imported into factors unless we set = FALSE.
5
Q
knitr
A
- Package in R which has the function kable which makes seeing factors easier.
6
Q
kable(argument)
A
- Function in knitr that will display a table where we can see factors above the top rows.
7
Q
as.numeric(object)
A
- Function that converts the entries of an object into numeric.
- We can use this to convert a factor to numeric.
8
Q
median (argument1,argument2)
A
- A function that gives the median of some object (such as the column of a data frame).
- The second option can be used to remove NA’s, such as na.rm = TRUE.