I'm looking for a function to get the original mapping table of factor variable. I import an Rdata file. I've got a factor variable named "FactVar". I know the mapping table for "FactVar" is as follows:
"010025" -> city1
"015146" -> city2
"048017" -> city3
"082053" -> city4
In my dataframe the "FactVar" data are as follows (first 5 cases):
1: city1
2: city3
3: city4
4: city1
5: city3
So, no "city2" in my df. Which function can I use to get the original mapping table? is it available in my Rdata file?
Thank you
EDIT: I try to clarify my question with a better example. I have a survey question with the following possible answers:
1: "Yes"
2: "No"
8: "Don't Know"
9: "Not Applicable"
I create a factor variable "FactVar":
Var <- c(1,2,1,2,2,2,1,8,1,2)
FactVar <- factor(Var, levels=c(1,2,8,9), labels=c("Yes", "No", "Don't Know", "Not Applicable")
As you see, in my Rdata file I've got a factor variable where no data are linked to the level "Not Applicable". How can I get the original mapping table as in my survey question?