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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

stringsAsFactors =

A
  • An option whose default is set equal to TRUE.

- Turns all the variables imported into factors unless we set = FALSE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

knitr

A
  • Package in R which has the function kable which makes seeing factors easier.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

kable(argument)

A
  • Function in knitr that will display a table where we can see factors above the top rows.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly