summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2014-11-01 10:40:43 -0500
committerLevi Bostian <levi.bostian@gmail.com>2014-11-01 10:40:43 -0500
commit145f5eae13decf2fb7bea2d4800a8e1b8f308fd8 (patch)
tree614b8337019181f4ed6a64550a418a9ed24b6ec3
parent752edae333d255850abdeb92a56333a1e0cb0020 (diff)
parenta32bb0a2cc3b53b4ffa4d2e93ebe664afb7a7729 (diff)
Merge pull request #843 from brunokim/patch-1
Remove misleading example of NA in Levels section
-rw-r--r--r.html.markdown11
1 files changed, 6 insertions, 5 deletions
diff --git a/r.html.markdown b/r.html.markdown
index 7cb56fd7..c555d748 100644
--- a/r.html.markdown
+++ b/r.html.markdown
@@ -179,7 +179,7 @@ c(3,3,3,2,2,1) # 3 3 3 2 2 1
# You can also have infinitely large or small numbers
class(Inf) # "numeric"
class(-Inf) # "numeric"
-# You might use "Inf", for example, in integrate( dnorm(x), 3, Inf);
+# You might use "Inf", for example, in integrate(dnorm, 3, Inf);
# this obviates Z-score tables.
# BASIC ARITHMETIC
@@ -236,11 +236,12 @@ 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 NA
+factor(c("female", "female", "male", NA, "female"))
+# female female male <NA> female
+# Levels: female male
# The "levels" are the values the categorical data can take
-levels(factor(c("male", "male", "female", "NA", "female"))) # "female" "male" "NA"
+# Note that missing data does not enter the levels
+levels(factor(c("male", "male", "female", NA, "female"))) # "female" "male"
# If a factor vector has length 1, its levels will have length 1, too
length(factor("male")) # 1
length(levels(factor("male"))) # 1