I have wind direction measurements and would like to assign labels to the numeric measurements (in degrees (0-360)).
I tried to use cut()
:
meteo$DWIND <- cut(meteo$DWND, breaks = c(0,22.5,67.5,112.5,157.5,202.5,247.5,292.5,337.5,360), labels = c("N", "NE", "E","SE","S","SW","W","NW","N"))
But this throws the following warning:
In
levels<-
(*tmp*
, value = if (nl == nL) as.character(labels) else paste0(labels, : duplicated levels in factors are deprecated
I understand that I use the label "N" twice and cut somehow does not like that idea. But this is exactly what I want. To assign the same label "N" to both bins 0-22.5 and 337.5-360.
Could you help me finding a way to achieve this?
labels = c("N", "NE", "E","SE","S","SW","W","NW","N2")
followed bymeteo$DWIND[meteo$DWIND=="N2"] = "N"
? – G5W