Share

10.9 Rename data by deleting a portion of the string

#Remove text using substring function
# (i.e., "2004_Resident_1315_Adult" to "Resident_1315_Adult")
awp$code <- substr(awp$res_mig1, 6, 24)

#Concatenate above with "Season" column to make unique categories
awp$season_code <- paste(awp$Season, awp$code, sep="_")

#Results in "Summer_Resident_1315_Adult"