Here is my data Frame "crime":
District Premise Weapon
313 99 99
316 NA
314 20 99
312 13 40
312 9 99
I have a separate list of what all the codes mean. For example, 99 in premise means "residence", 20 means "Street". 99 in Weapon means "hands", 40 means "blunt object".
In another post on stackflow, I was able to use the following code for my purpose:
crime$Premise[crime$Premise == 13] <- "House"
This worked but I realized I have 30 different codes in Premise and Weapon. There has to be a more efficient way of writing the code instead of copy and pasting the code above in multiple times and replacing the integer with the string.
*note, 99 means something else under Premise and something else in Weapon.
What is the best way to write this, so I can replace all the numbers with corresponding codes? Thank you in advance!