Skip to content
Prev 24751 / 29559 Next

Incorrect month order in zApply function

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.