diff options
author | Hank Hester <hankhester@github.com> | 2021-01-15 02:30:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 11:30:42 +0100 |
commit | c351cab657897229e1d6b826a53399bca129b489 (patch) | |
tree | b6d39c0292f768512df85d91d0f38432a2791177 /r.html.markdown | |
parent | ab85932812de0ee13707400c69ffa90bd619aea6 (diff) |
Remove binary gender example from R (#4082)
Diffstat (limited to 'r.html.markdown')
-rw-r--r-- | r.html.markdown | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/r.html.markdown b/r.html.markdown index 3e855602..79af40ce 100644 --- a/r.html.markdown +++ b/r.html.markdown @@ -255,16 +255,16 @@ c('Z', 'o', 'r', 'r', 'o') == "Z" # TRUE FALSE FALSE FALSE FALSE # FACTORS # The factor class is for categorical data -# Factors can be ordered (like childrens' grade levels) or unordered (like gender) -factor(c("female", "female", "male", NA, "female")) -# female female male <NA> female -# Levels: female male +# Factors can be ordered (like childrens' grade levels) or unordered (like colors) +factor(c("blue", "blue", "green", NA, "blue")) +# blue blue green <NA> blue +# Levels: blue green # The "levels" are the values the categorical data can take # Note that missing data does not enter the levels -levels(factor(c("male", "male", "female", NA, "female"))) # "female" "male" +levels(factor(c("green", "green", "blue", NA, "blue"))) # "blue" "green" # If a factor vector has length 1, its levels will have length 1, too -length(factor("male")) # 1 -length(levels(factor("male"))) # 1 +length(factor("green")) # 1 +length(levels(factor("green"))) # 1 # Factors are commonly seen in data frames, a data structure we will cover later data(infert) # "Infertility after Spontaneous and Induced Abortion" levels(infert$education) # "0-5yrs" "6-11yrs" "12+ yrs" |