Share

10.12 Recode numeric values as factors into categories

#Originally we have multiple numbers of GPS locations that we want to recode into #categories 1-4 or some other descriptor.
#We will give NBLOCS a new name (LocsCat) in our dataframe, make it a factor (as.factor) then #include breaks that we want to represent each category.
#For example, 0:100 represents category 1 with locations from 0 to 100 m

merge$LocsCat <- as.factor(recode(merge$NBLOCS, "0:100=’1’;101:500=’2’; 501:1000=’3’; 1001:10000=’4’"))