I am trying to group some wind direction data to text in a new column of a data frame, following the 16 directions (N, NNE, NE etc), but I can't seem to work out an error message.
This is the code:
RW_Baza[, Aspect_16] <- cut(RW_Baza$Aspect.grade,
breaks = c(-Inf, 11.25, 33.75, 56.25, 78.75, 101.25, 123.75, 146.25, 168.75, 191.25, 213.75, 236.25, 258.75, 281.25, 303.75, 326.25, 348.75, Inf),
labels = c("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"),
right=FALSE)
I get this error message:
In levels<-
(*tmp*
, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated.
N
s in your data, which is a no no for factors. Assign it using a temp value first and then substitute – ChrisRW_Baza[Aspect_16 == "NN",] <- "N"
That process will change the level of all values of "NN" (17) to "N" (1) – Chris