[R-sig-Geo] Incorrect month order in zApply function
Thiago V. dos Santos
thi_veloso at yahoo.com.br
Thu Aug 4 19:07:00 CEST 2016
Thanks for the information, Oscar. Perhaps it would be a good idea to include it in the zApply description within the raster manual?
Best, Thiago.
Sent from Yahoo Mail on Android
On Thu, Aug 4, 2016 at 3:19 AM, Oscar Perpiñán Lamigueiro<oscar.perpinan at upm.es> wrote: 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
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list