[R] Assigning values based on a separate reference (lookup) table
daniel at umd.edu
Fri Aug 14 21:17:14 CEST 2009
Once you have the long format of the dataset, you could just code a "bin"
variable and merge with this bin variable instead. Piece o' cake, ain't it?
cuncta stricte discussurus
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von Steve Murray
Gesendet: Friday, August 14, 2009 3:05 PM
An: dmalter at rhsmith.umd.edu; r-help at r-project.org; jholtman at gmail.com
Betreff: Re: [R] Assigning values based on a separate reference (lookup)
Thanks to you both for your responses.
I think these approaches will *nearly* do the trick, however, the problem is
that the reference/lookup table is based on 'bins' of latitude values,
eg.>61, 60-56, 55-51, 50-46 etc. whereas the actual data (in my 720 x 360
data frame) are not binned, e.g. 89.75, 89.25, 88.75, 88.25, 87.75 etc. -
instead they 'increment' by -0.5 each time, and therefore many of the 367200
values which are in the data frame will have latitude values falling into
the same 'reference' bin.
It's for this reason that I think the 'merge' approach might fall down,
unless there's a way of telling 'merge' that latitude can still be
considered to match if they fall within a range. For example, if my 720 x
360 data frame has values whose corresponding latitude (row name) values
are, say, 56.3, 55.9, 58.2, 56.8 and 57.3, then the original value in the
grid needs to be assigned a 'p' value which corresponds with what is read
off of the reference table from the bin 56-60.
Hope this makes sense! If not, please feel free to ask for clarification.
Many thanks again,
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help