How to access the vector by logical indexing in R

r

#1

I have studied that any vector can be access by
1-numeric
2- names
3- logicals
but I am not able to access through logical
x<-c(1,2,3)
names(x)<-c(“M”,“T”,“W”)
x[1]
M
1
x[“M”]
M
1

I want to access the first element through logical indexing


#2

@sid100158, please go through this example to understand logical indexing.

http://www.r-tutor.com/r-introduction/vector/logical-index-vector


#3
x[x == 1]

#or

x[c(TRUE, FALSE, FALSE)]