From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Mon, 23 Jun 2008 14:35:22 -0400

R-help_at_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. Received on Mon 23 Jun 2008 - 18:57:48 GMT

Date: Mon, 23 Jun 2008 14:35:22 -0400

Just add a column to E.corr that is 1, 2, ...

E.coor$id <- 1:nrow(E.coor)

and now repeat the merge and SQL solutions.

On Mon, Jun 23, 2008 at 1:49 PM, <jgarcia_at_ija.csic.es> wrote:

> Thanks for your answers.

*> I'm sorry. I'm afraid I didn't pose correctly the question , and the use
**> os "subset" was misleading. What I need is to obtain the index of the
**> corresponding rows in E.coor, to subtitute the corresponding values by new
**> updated values.
**>
**> The closest answer to what I really need is that of Jim Holtman, but it
**> does not seem to work correctly as it does not check that the two
**> conditions (equal East, and equal North) apply simultaneously for each
**> individual row. e.g, let's suposse E.coor and subset.coor are exactly:
**>
**>> E.coor
**> east north dat
**> 1 582650 4248850 0.8316848
**> 2 582750 4248850 0.7230272
**> 3 582850 4248850 0.3250818
**> 4 582950 4248850 0.6144006
**> 5 583050 4248850 0.8706312
**> 6 583150 4248850 0.2149651
**> 7 583250 4248850 0.1659519
**> 8 583350 4248850 0.2145174
**> 9 583450 4248850 0.1615151
**> 10 582950 4248850 0.9370766
**>> subset.coor
**> east north newdat
**> 1 582650 4248850 1.2
**> 4 582950 4248850 2.5
**> 6 583150 4248850 0.6
**>> E.coor[E.coor$east %in% subset.coor$east & E.coor$north %in%
**> subset.coor$north,]
**> east north dat
**> 1 582650 4248850 0.8316848
**> 4 582950 4248850 0.6144006
**> 6 583150 4248850 0.2149651
**> 10 582950 4248850 0.9370766
**>
**> while I didn't intent to get the row 10
**>
**> So, I can not use this syntax to substitute E.coor[c(1,4,6),"dat"] by the
**> new corresponding values subset.coor[,"newdat"].
**>
**> I'm Sorry for my previously badly posed problem.
**>
**> Any suggestion about this?
**>
**> Javier
**> ---------
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>> You can also do this:
**>>
**>>> E[(E$east %in% sub$east) & (E$north %in% sub$north),]
**>> east north dat
**>> 1 582650 4248850 0.8316848
**>> 7 583250 4248850 0.1659519
**>>>
**>>
**>>
**>> On Mon, Jun 23, 2008 at 12:32 PM, <jgarcia_at_ija.csic.es> wrote:
**>>> This should be theoretically very simple, but I dont get the elegant
**>>> answer (without looping).
**>>>
**>>> I've got a long (thousands of rows) data frame:
**>>>
**>>>> E.coor[1:10,]
**>>> east north dat
**>>> 1 582650 4248850 0.8316848
**>>> 2 582750 4248850 0.7230272
**>>> 3 582850 4248850 0.3250818
**>>> 4 582950 4248850 0.6144006
**>>> 5 583050 4248850 0.8706312
**>>> 6 583150 4248850 0.2149651
**>>> 7 583250 4248850 0.1659519
**>>> 8 583350 4248850 0.2145174
**>>> 9 583450 4248850 0.1615151
**>>> 10 583550 4248850 0.9370766
**>>>
**>>> and need to extract those with the coordinates coinciding with those in
**>>> a
**>>> smaller data frame (about one hundred rows):
**>>>
**>>>> subset.coor
**>>> east north
**>>> 20 584550 4248850
**>>> 21 584650 4248850
**>>> 22 584750 4248850
**>>> 23 584850 4248850
**>>> 24 584950 4248850
**>>> 25 585050 4248850
**>>>
**>>> i.e, I need the ~ one hundred E.coor rows that appear in subset.coor
**>>>
**>>> Could you help with this.
**>>>
**>>>
**>>> Best regards,
**>>> Javier
**>>> ---------
**>>>
**>>> ______________________________________________
**>>> R-help_at_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.
**>>>
**>>
**>>
**>>
**>> --
**>> Jim Holtman
**>> Cincinnati, OH
**>> +1 513 646 9390
**>>
**>> What is the problem you are trying to solve?
**>>
**>
**> ______________________________________________
**> R-help_at_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.
**>
*

R-help_at_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. Received on Mon 23 Jun 2008 - 18:57:48 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 23 Jun 2008 - 20:32:58 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*