I would like to do a simple if statement to group codes into groups. The variable has number codes and I would like to create a new variable that groups several number codes together. I have written the following if statement but because they are many code numbers (30 codes), I need help writing a more elegant code to group the variable rather than writing 30+ if statements.
Data2$RevisedSIC.Group <-c()
for (i in 1:length(Data2$SIC.Group )) {
if (Data2$SIC.Group[i] =="10110") Data2$RevisedSIC.Group [i]="Metal" else
if (Data2$SIC.Group[i] =="10410") Data2$RevisedSIC.Group [i]="Metal" else
if (Data2$SIC.Group[i] =="10439") Data2$RevisedSIC.Group [i]="Metal" else
if (Data2$SIC.Group[i] =="14111") Data2$RevisedSIC.Group [i]="Stone" else
if (Data2$SIC.Group[i] =="10421") Data2$RevisedSIC.Group [i]="Stone" }