[GRASS-stats] Load data multiple data from grass to R

Roger Bivand Roger.Bivand at nhh.no
Fri Nov 23 09:15:16 EST 2007


On Fri, 23 Nov 2007, Jarek Jasiewicz wrote:

> This another wuestion which probably has very simple solution:
>
> I try to create single object wich is list of list (from the result of 
> density() function
>
> it is very simple:
> raster_dens=list(dens_1, dens_2...,dens_78)
>
> except that I must to do it manually
>
> I try to do it with script:
>
> raster_dens=list()
>
> for (i in seq(1:78)) {
> append(raster_dens, 
> density(na.omit(raster[[i]]),bw=(max(na.omit(raster[[i]]))-min(na.omit(raster[[i]]))/50)))
> }
> density() returns list of 7, but I cannot ad it to raster_dens
>
> If I do it with SpGridDataFrame, all go OK
>
> So why I cannot do this there?

In general, create a list of the right length first, and do

raster_dens[[i]] <- density(na.omit(raster[[i]]), ...

to avoid object copying on appending or concatenation. Then you'll get a 
list of lists.

Hope this helps,

Roger

>
> Jarek
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the grass-stats mailing list