[R-sig-Geo] Incorrect month order in zApply function

Oscar Perpiñán Lamigueiro oscar.perpinan at upm.es
Thu Aug 4 10:19:06 CEST 2016


Hello,

With the current code of zApply, you should use a function that returns an ordered vector. For example:

Month <- function(x)
{
    idx <- as.numeric(format(x, '%m'))
    factor(month.name[idx],
           levels = month.name,
           ordered = TRUE)
}


x2 <- zApply(s, by = Month, mean)

Best,

Oscar.
-- 
Oscar Perpiñán Lamigueiro
Dpto. Ing. Eléctrica, Electrónica, Automática y Física Aplicada
Escuela Técnica Superior de Ingeniería y Diseño Industrial
URL: http://oscarperpinan.github.io



More information about the R-sig-Geo mailing list