You probably want something like this is there are multiple tags you
are matching on (?paste):
> TazProperties2..$Area<-TazProperties..$Area[match(
+ paste(TazProperties2..$Props2, TazProperties2..$TAZ2),
+ paste(TazProperties..$Props, TazProperties..$TAZ))]
> TazProperties2..
Props2 TAZ2 Area
1 p754921 38 109828.04
2 p754921 37 128134.71
3 p754921 37 128134.71
4 p75506 171 37160.21
5 p75506 171 37160.21
6 p75506 282 344679.66
7 p75506 171 37160.21
8 p75508 46 342309.56
9 p75508 46 342309.56
10 p75508 169 17014.66
11 p75508 169 17014.66
12 p75508 169 17014.66
>
But even that is not sufficient since even using that, it does not
given unique values since in your first one you have multiple entries
with 'p75508 169'. If they are the same lengths, then just copy the
data, otherwise you are going to have to add another tag to make sure
you can do a unique match. You might try to use 'merge'.
On Tue, Feb 23, 2010 at 11:08 AM, ROLL Josh F <[email protected]> wrote:
> 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:[email protected]]
> Sent: Monday, February 22, 2010 9:06 PM
> To: ROLL Josh F
> Cc: [email protected]
> 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 <[email protected]> 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.
>>
>> ______________________________________________
>> [email protected] 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.
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
______________________________________________
[email protected] 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.