I have a data and its dput
is given below.
Data:
dput(data)
structure(c(12L, 2L, 14L, 2L, 2L, 12L, 14L, 13L, 14L, 12L), .Label = c("0 Ã 10 cm",
"10 Ã 20 cm", "100 Ã 110 cm", "110 Ã 120 cm", "120 Ã 130 cm",
"130 Ã 140 cm", "140 Ã 150 cm", "150 Ã 160 cm", "160 Ã 170 cm",
"170 Ã 180 cm", "180 Ã 190 cm", "20 Ã 30 cm", "30 Ã 40 cm",
"40 Ã 50 cm", "50 Ã 60 cm", "60 Ã 70 cm", "70 Ã 80 cm", "80 Ã 90 cm",
"90 Ã 100 cm", "N/A"), class = "factor")
The data is french, basically, it is categories from 0 to 10, from 10 to 20 and so on. I need to replace the second column with numbers, for example, 0 Ã 10 cm I need to assign to 1, 10 Ã 20 cm - to 2 and so on, how can I automatically replace values with the number based on the category in R?
In the new table, I need to get column 2 replacing the A
with the category levels and the column 2 will have values as given below.:
2 1 4 1 1 2 4 3 4 2