There may be a problem.

mapply(function(a, b, c) exp(a), A, B, C)


alas

> exp(A[[1]])
> class       : RasterLayer
> dimensions  : 2, 2, 4  (nrow, ncol, ncell)
> resolution  : 0.5, 0.5  (x, y)
> extent      : 0, 1, 0, 1  (xmin, xmax, ymin, ymax)
> coord. ref. : NA
> data source : in memory
> names       : layer
> values      : 2.718282, 54.59815  (min, max)


Looks like exp() doesn't work from inside `mapply`. Robert?

# I changed c to d, because it's hell to debug `c`

D <- mapply(function(a, b, d) {
>   browser()

  1/(1 - exp(-exp(-((a - b)/d))))
> }, A, B, C)



Browse[1]> class(a)
> [1] "RasterLayer"
> attr(,"package")
> [1] "raster"
> Browse[1]> exp(a)
> Error in as.character(sys.call(sys.parent())[[1]]) :
>   cannot coerce type 'closure' to vector of type 'character'




Cheers,
Roman



On Mon, Feb 11, 2013 at 2:14 PM, Lorenzo Alfieri <alfio...@hotmail.com>wrote:

>
> Dear list,
> I'm trying to apply a function to lists of rasters, but without success.
> I'm not sure if it feasible of if I should use a for loop.
> Let's say a, b and c are three lists of argument to my function
>  1/(1-exp(-exp(-((a - b)/c))))  (2 rasters each)
> I'd like this function to be applied to these arguments, so that I get as
> result a list D of 2 rasters, where for example
> D[[1]] = 1/(1-exp(-exp(-((A[[1]] - B[[1]])/C[[1]])))) and the same for
> D[[2]]
>
> I tryed with this but didn't work:
>
> library(raster)
>
> aa<-matrix(c(2,1,3,4),nrow=2,ncol=2)
> bb<-matrix(c(5,7,4,6),nrow=2,ncol=2)
> cc<-matrix(c(12,13,17,16),nrow=2,ncol=2)
> A<-list(raster(aa),raster(t(aa)))
> B<-list(raster(bb),raster(t(bb)))
> C<-list(raster(cc),raster(t(cc)))
>
> D<-mapply(function(a,b,c) 1/(1-exp(-exp(-((a - b)/c)))), A,B,C)
>
> Any suggestions?
>
> Lorenzo
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
In God we trust, all others bring data.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to