I have a datatable, dataframe which has a variable: grade_c:Factor w/8 Level. 0, A, B, C, D, E, F, NA
And I want to change the variables to ->
0-> NA
A-> 1
B-> 2
C-> 3
...
F-> 6
I saw that I can recode variables with this code:
NonTestMergeV$grade_c[NonTestMergeV$grade_c=="A"] <- 1
But when I try it I get this warning. And nothing changes...
Warning message: In
[<-.factor
(*tmp*
, NonTestMergeV$grade_c == "A", value = c(NA, : invalid factor level, NA generated
Any help on how to get the desired result would be helpful. Thank you!