Re: [R] Return Vector Component

2012-11-01 Thread arun
10   #this means 4th and 10 element of res2 matches with first element of v1[1]   res2[4] #[1] "age_1_height_1" #The goal is to get the corresponding element of v2 that matches with v1.  Since the order of res2 and v2 are the same, we can index it to get the matching v2 #elements

Re: [R] Return Vector Component

2012-11-01 Thread arun
grep(v1[8],res1)] #[1] "age_height_2_2" A.K. - Original Message - From: frespider To: r-help@r-project.org Cc: Sent: Thursday, November 1, 2012 10:20 AM Subject: Re: [R] Return Vector Component Hi A.K. Thank you so much for replying this could work but the problem you rec

Re: [R] Return Vector Component

2012-11-01 Thread frespider
Hi A.K. Thank you so much for replying this could work but the problem you recreate the newv1, to match v2 but I don't want to do that. I just want to check if v2 has that component from v1 THanks Date: Thu, 1 Nov 2012 06:32:03 -0700 From: ml-node+s789695n4648123...@n4.nabble.com To: frespi

Re: [R] Return Vector Component

2012-11-01 Thread arun
-paste0(v3[grep("age",v3)],v5[grep("height",v5)],v4[!v4%in%v4[grep("height",v4)]],"_",v6[!v6%in%v6[grep("age",v6)]]) newv1[newv1%in%v2] #[1] "age_height_1_1" "age_height_2_2" "age_height_3_3" "age_height_4

[R] Return Vector Component

2012-11-01 Thread frespider
Hi, I am new R user and I am still learn this fabulous software. I am stuck on this part. I need to check 2 character vectors v1 <- c("age_1","age_2","age_3","age_4","age_5","age_6","height_1","height_2","height_3","height_4","height_5","height_6","height_7","height_8") and v2 <- c("sex_1","s