[R] help with this indexing

From: javier garcia-pintado <jgarcia_at_ija.csic.es>
Date: Mon, 21 May 2007 16:32:43 +0200


Hi all,
Let's say I have a long data frame and a short one, both with three colums: $east, $north, $value
And I need to fill in the short$value, extracting the corresponding value from long$value, for coinciding $east and $north in both tables. I know the possibility:

for (i in 1:length(short$value)){
 short$value[i] <- long$value[long$east==short$east & long$north==short$north]
}

How could I avoid this loop?

Thanks and regards,

Javier

--

Javier García-Pintado
Institute of Earth Sciences Jaume Almera (CSIC)
Lluis Sole Sabaris s/n, 08028 Barcelona
Phone: +34 934095410
Fax:   +34 934110012
e-mail:jgarcia_at_ija.csic.es 



______________________________________________ R-help_at_stat.math.ethz.ch 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 21 May 2007 - 14:41:11 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 21 May 2007 - 15:31:32 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.