Please consider the following: Puma=c(702, 702, 701, 702, 701, 702, 701, 702 ,702 ,702 ,701 ,702, 702, 701 ,701, 702, 701 ,702, 702, 702,701, 702 ,702 ,702 ,701) PumaNums=c(100 , 200 , 300 , 400 , 500 , 600 , 701 , 702 , 800 , 900 ,1000 ,1101, 1102, 1200 ,1301 ,1302 ,1303, 1304, 1305, 1306, 1307 ,1308 ,1309 ,1310 ,1311 ,1312 ,1313)
PumaNames<-c("Northeast", "NorthCentral", "Southeast", "Deschutes", "NorthCoast", "BentonLinn", "Lane", "Eugene", "CoosCurryJosephine", "Jackson", "Douglas", "Salem", "Marion", "PolkYamhill", "Portland", "Portland", "Portland", "Portland", "Portland", "Portland", "ClackamasMultnomah", "Portland", "Portland", "Portland", "Washington", "Portland", "Portland") PumsAreaNames=data.frame(PumaNums,PumaNames) HhSerialno<-c( 38 , 71 , 80, 100, 100 ,106, 126 ,152 ,157 ,181 ,182 ,210 ,244, 267 ,296 ,361, 387, 399, 430 ,434 ,468 ,480 ,483 ,486 ,532) Hhdata<-data.frame(HhSerialno,Puma) IsEugene <- Hhdata$Puma %in% PumsAreaNames..$PumaNums[(PumsAreaNames..$PumaNames == "Eugene")] #------------------------------------------ Is Eugene returns a true/false for whether the Hhdata$Puma attribute matches 'Eugene". I would also like it to associate the serial number but not in a dataframe form but rather like the following: FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 9995828 9995840 9995843 9996259 9996287 9996375 9996581 9996724 9996796 9997176 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 9997492 9997546 9997664 9997924 9998062 9998073 9998216 9998682 9998691 9998721 FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE 9998740 9999082 9999198 9999331 9999390 9999805 9999811 FALSE FALSE FALSE FALSE FALSE FALSE FALSE Where the numerics are the serial number. The reason i am having trouble is that i am using some existing code and the desired above is what is returned form the original code and the new code returns just the logical values. I have done the obvious and made sure my data is in the correct format which it is so i am wondering if i can just figure out how to move to what i need. Thanks everyone. JR -- View this message in context: http://www.nabble.com/creating-selection-vector-with-2-attributes-tp24909595p24909595.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.