I'm trying to find the per cell median across a set of rasters in R, but when I use the median
function I get the following error:
Error in if (any(is.na(x))) return(x[FALSE][NA]) :
argument is not interpretable as logical
However, I can perform max
, mean
and calc(r, median)
on my stack so I suspect that it isn't an issue with data format (tif). The code I'm using is:
Load data:
f = list.files("./")
r = stack(f)
Do sums:
median(r) # does not work
mean(r) # works
max(r) # works
calc(r, median) # works
As calc
is working I don't need an answer to proceed, but I would like to understand why median
isn't working. Is this standard behaviour?
median
is not a summary method available for Raster* objects. Available summary methods are currentlymean
,max
,min
,range
,prod
,sum
,any
andall
. Source: reference manual, page 201 – Pollard