Hi,
myvector<- c(3,2,7,4,1)
names(myvector)<-paste0("name",1:5)
names(myvector)[myvector>=3 & myvector<=5] 
#[1] "name1" "name4"
#or
names(myvector)[myvector%in% 3:5]
#[1] "name1" "name4"

#or

 names(myvector)[!is.na(match(myvector,3:5))]
#[1] "name1" "name4"



A.K.


Hello all, 
I am new to R but trying to learn. 

I have a vector of names with visit frequencies (myvector) in the form 

name1 name2 name3 name4 name5 
3              2            7            4            1 

I can select names of patients that have visited more often: 

frequent.pats<-names(myvector) [myvector>5] 

or those that have visited less often, but how could I get the names of those 
who visited, say between 3&5 times? 
Thanks 
steele

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to