Share

10.11 Rename levels of factor

#Original age classes

# 2-5# 3# 6+#Adult# Calf# Yearling
188 1 79 5 36 30

#Recode variables within a column that are factors such as combining age classes

#Combine ages classes
df$NewAge <- df$Age
levels(df$NewAge)<-list(Yearling=c("Calf","Yearling"),Adult=c("2-5","3","6+","Adult"))

summary(df$NewAge)

#Yearling# Adult
66 273