[R-sig-Geo] raser::boxplot : cannot add grouping layer

Agustin Lobo alobolistas at gmail.com
Fri Oct 9 09:30:13 CEST 2015


Solved just by upgrading raster.
Thanks
Agus

On Thu, Oct 8, 2015 at 9:57 PM, Robert J. Hijmans <r.hijmans at gmail.com> wrote:
> Hi Agus,
> Your example works for me without error.
> Can you update.packages() and try this in a clean workspace? (perhaps
> another package is interfering?)
> Robert
>
> On Wed, Oct 7, 2015 at 2:44 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
>> According to the help page of raster::boxplot
>> x: Raster* object
>> y: if x is a RasterLayer object, y can be an additional RasterLayer to
>> group the values of x by 'zone'
>>
>> but I get an error when I add a raster layer that represents a classification:
>> r1 <- r2 <- r3 <- raster(ncol=10, nrow=10)
>> r1[] <- rnorm(ncell(r1), 100, 40)
>> r2[] <- rnorm(ncell(r1), 80, 10)
>> r3[] <- rnorm(ncell(r1), 120, 30)
>> s <- stack(r1, r2, r3)
>> names(s) <- c('A', 'B', 'C')
>>
>> rc <- round(r1[[1]]/100)
>> hist(rc)
>> summary(rc)
>>
>> boxplot(s[[1]],rc)
>>
>> Error in as.data.frame.default(data) :
>>   cannot coerce class "structure("RasterLayer", package = "raster")"
>> to a data.frame
>>
>> Am I not interpreting what this function is supposed to do? I want to
>> get the boxplot
>> of the values of s by class in rc
>> (i can do it having rc as an sp pol data frame and using extract,  but
>> thought raster::boxplot
>> would be a more direct way)
>>
>> Thanks
>>
>> Agus
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list