[R] matching on two criteria

LCOG1 jroll at lcog.org
Mon Feb 22 23:42:44 CET 2010



Howdy y'all,

I am looking to use the match function to match a data attribute to another
data frame but i need it to do so on two criteria to ensure an appropriate
match.  The following matches incorrectly.  I know the example looks
pointless but its just an example.  Perhaps there is another way of doing
this?  Thanks

#Sample Data
Props<-c("p754921","p754921" ,"p754921","p75506" ,"p75506" 
 ,"p75506","p75506" 
 ,"p75508","p75508","p75508","p75508","p75508") 
 TAZ<-c(38,37,37,171,171,282,171,46,46,169,169,169) 
 Area<-c(109828.04,  128134.71,   46469.57, 37160.21, 
 40080.50,344679.66,16972.28, 
 342309.558, 260906.870,  17014.659,   7285.706,  10936.316) 
#Creat 1st dataframe
TazProperties..<-data.frame(Props,TAZ,Area)
 #Sample Data
Props2<-c("p754921","p754921","p754921","p75506" ,"p75506" 
 ,"p75506","p75506" ,"p75508","p75508","p75508","p75508","p75508") 
 TAZ2<-c(38,37,37,171,171,282,171,46,46,169,169,169) 
#Create 2nd data frame
TazProperties2..<-data.frame(Props2,TAZ2) 

#match on prop and return area to data frame
TazProperties2..$Area<-TazProperties..$Area[match(TazProperties..$Props,TazProperties..$Props)]

-- 
View this message in context: http://n4.nabble.com/matching-on-two-criteria-tp1565265p1565265.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list