First, I have read some similar questions. My question is very similar to those which have been already solved. But the slight difference causes some problems for me.
In my question, I have a column of data frame with five different levels of strings: "10-20%" "100+%" "21-40%" "41-70%" "71-100%". I have tried both function, as.numeric and as.integer. These two functions did change the strings into numeric responses. The problem is that I want to convert these strings by following the numerically sequence. For example, "10-20%" "100+%" "21-40%" "41-70%" "71-100%", each of the string is corresponding to the strings is 1,2,3,4,5.
But the thing I want is to "10-20%" is 1, "21-40%" is 2, "41-70%" is 3, "71-100%" is 4 and "100+%" is 5. Do I have to change the sequence of levels of these strings Manually if I want to achieve my goal?
Appendix:
levels(dataset$PercentGrowth)
[1] "" "10-20%" "100+%" "21-40%" "41-70%" "71-100%"
head(as.integer(dataset$PercentGrowth))
[1] 1 4 3 1 3 4
head(as.numeric(dataset$PercentGrowth))
[1] 1 4 3 1 3 4
head((dataset$PercentGrowth))
[1] 21-40% 100+% 100+% 21-40%
Levels: 10-20% 100+% 21-40% 41-70% 71-100%