[R] Assigning values based on a separate reference (lookup) table

Steve Murray smurray444 at hotmail.com
Fri Aug 14 19:48:44 CEST 2009

Dear R Users,

I have a data frame of 360 rows by 720 columns (259200 values). For each value in this grid I am hoping to apply an equation to, to generate a new grid. One of the parts of the equation (called 'p') relies on reading from a separate reference table. This is Table 4 at: http://www.fao.org/docrep/s2022e/s2022e07.htm#3.1.3%20blaney%20criddle%20method (scroll down a little).

Therefore, 'p' relies on the latitude of the values in the initial 360 x 720 data frame. The row names of the data frame contain the latitude values and these range from between 89.75 to -89.75 (the latter being South of the Equator).

My question is, how do I go about forming a loop to read each of the 259200 values and assign it a 'p' value (from the associated reference table), based on it's latitude?

My thinking was to do a series of 'if' statements, but this soon got very, very messy - any ideas which get the job done (and aren't a riddle to follow), would be most welcome.

Many thanks for any advice,



[[elided Hotmail spam]]

More information about the R-help mailing list