Ian, As you need interpolation, perhaps the loess function is useful for you ((although I wonder whether you need a lookup table. Wouldn't you rather use an existing function to predicts svp from temp))?
tab = data.frame(temp=-10:9,svp= 1:20) mat = matrix(20:-29, byrow=T, nrow=5)/2 mat model = loess(svp~temp, data=tab) mat2 = predict(model, as.vector(mat)) dim(mat2) = dim(mat) mat2 # only matching integers: m = cbind(as.vector(mat), 1:length(mat)) m = merge(m, tab, by=1, all.x=T) m = m[order(m[,2]), 3] dim(m) = dim(mat) m Robert On Thu, Feb 4, 2010 at 1:12 AM, Ian McCallum <mccal...@iiasa.ac.at> wrote: > Greetings All, > Firstly - thanks for previous answers on exporting to asciigrid! > > Now i have a matrix (grid) of temperature, > and a lookup table of temperature and svp. > > I would like to create a new matrix with corresponding svp values. > > This is relatively straightforward in a GIS - but i have not found a way in R. > Ideally it would also interpolate between values in the lookup table. > Options like merge, cbind, may work?? > Without looping would be ideal. > > any ideas? > thanks! > Ian > > # test matrix > mat = matrix(-49.5:50,10,10) > > # test lookup table > temp = -10:9 > svp = 1:20 > tab = data.frame(temp,svp) > > > ___________________________________________ > > Ian McCallum > Forestry Program > International Institute for Applied Systems Analysis > Schlossplatz 1, A-2361 Laxenburg, Austria > Phone: +43 2236 807-328 > Fax: +43 2236 807-599 or 71313 > E-mail: mccal...@iiasa.ac.at > Web: http://www.iiasa.ac.at/Research/FOR/ > ___________________________________________ > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo