Assuming I have a matrix of  Nrows and Mcols  where
Column #1 is filled with a valid cell number for a raster. ALL cell numbers
will not
  be present.

Subsequent columns (2-M) contain the data that I want to place in a sequence
of
layers, so that in the end I have a rasterStack of M layers. M can be quite
large,
( like 1000-2000) Essentially they are values at various time slices where
time
is M.

In any case, if there is only one layer ( column 2) then assigning the
values in column
2 to the cells in column 1 is straightforwd (assuming I read the manual
correctly.

That works like this:
( Create a dummy version of the data with 200 cells)

stackmatrix<-matrix(NA,nrow=200,ncol=3)
# fake values
 stackmatrix[,3]<-seq(0,199,by=1)
 stackmatrix[,2]<-seq(-59.9,-79.8,by=-.1)
# toss some valid cell numbers in column 1
 stackmatrix[,1]<-seq(100,299,by=1)
globe<-raster(nrows=36, ncols=72, xmn=-180, xmx=180, ymn=-90, ymx=90,
+   projs="+proj=longlat +datum=WGS84")
# assign the values in column 2 to the cells in column 1.
globe[stackmatrix[,1]]<-stackmatrix[,2]


If I have a large number of columns and I want to create a large rasterStack
with all the data, is there a slick way to do it

Perhaps apply?

	[[alternative HTML version deleted]]

