Why am I getting NA?

I'm very new to RStudio so I apologize for this simple question but I don't understanding why when I type
c(0:5)[NA]
NA NA NA NA NA

Is it because its trying to retrieve NA's in the sequence and there are none so it gives me NAs? or is it that I've told the system to make a sequence with 5 NA?

c(0:5) creates the vector

[1] 0 1 2 3 4 5

The subset operation returns the elements with the values of NA. Consider

c(0:5) -> a
a
#> [1] 0 1 2 3 4 5
a[NA]
#> [1] NA NA NA NA NA NA
a[1]
#> [1] 0
is.na(a)
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE

Created on 2020-10-09 by the reprex package (v0.3.0.9001)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.