I have problems understanding this. I have an integer vector of length 5:
x <- 1:5
If I index it with a single NA
, the result is of length 5:
x[NA]
# [1] NA NA NA NA NA
My first idea was that R checks whether 1-5 is NA
but
x <- c(NA, 2, 4)
x[NA]
# NA NA NA.
So this cannot be the solution. My second approach is that x[NA]
is indexing but then I do not understand
- Why this gives me five
NA's
- What NA as an index means.
x[1]
gives you the first value but what should be the result of x[NA]
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…