Ah yes you are correct, my apologies. TazProperties2..$Area<-TazProperties..$Area[match(TazProperties..$Props,TazProperties..$Props)] should be TazProperties2..$Area<-TazProperties..$Area[match(TazProperties2..$Props,TazProperties..$Props)]
As is this does give me what i want sort of. The problem is it retunrs the same area value for all of the prop ids so i need to use a two level match and utilize another attribute to ensure the correct match. Sorry for the sample error ________________________________ From: jim holtman [mailto:jholt...@gmail.com] Sent: Monday, February 22, 2010 9:06 PM To: ROLL Josh F Cc: r-help@r-project.org Subject: Re: [R] matching on two criteria Exactly what results are you expecting? Your 'match' has the same variables in both locations and will therefore return the first match: > match(TazProperties..$Props,TazProperties..$Props) [1] 1 1 1 4 4 4 4 8 8 8 8 8 so you are getting the results that you ask for. On Mon, Feb 22, 2010 at 5:42 PM, LCOG1 <jr...@lcog.org<mailto:jr...@lcog.org>> wrote: 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. ______________________________________________ R-help@r-project.org<mailto: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<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] ______________________________________________ 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.