The following solution uses the UCI mushroom dataset that can be found here: https://archive.ics.uci.edu/ml/datasets/Mushroom. The following creates a data frame and subset of this data while populating the data with accurate and meaningful values and names.

  1. Load the data found at the above URL.
m1<-read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data", header= FALSE, sep=",")
options(warn=-1)
  1. Create a subset of data and rename the empty column with appropriate fieldnames.
m2 <- m1[,c("V1","V4", "V22", "V23")]
colnames(m2) <- c("class", "color", "population","habitat")
  1. Create a lookuptable csv that defines each character values associated with each field.
lu<-read.csv("http://delineator.org/storage/lu_mushrooms.csv", sep=",")
  1. There are a few directions we can take with the data at this point. In this instance, with these particular field types, I was able to solve this problem using a simple method that concatenates unique field names with their character values, thereby removing duplicate identities. For instance, having ‘p’ needing to become ‘poisonous’, it now becomes ‘class p’ needing to become poisonous. The following concatenates these cells in both data frame columns.
lu$concat <- do.call(paste, c(lu[c("column", "code")], sep = "")) 
m2$concat_class <- paste("class",m2$class)
m2$concat_color <- paste("color",m2$color)
m2$concat_population <- paste("population",m2$population)
m2$concat_habitat <- paste("habitat",m2$habitat)
  1. Once the field have been processed using concatentation, we can then merge these values, in a fashion similar to a sql join. Run head(m2) for further clarification of this step.
lu = setNames(lu,c('column','code','change', 'concat_class'))
m3=merge(m2,lu,by="concat_class")

lu = setNames(lu,c('column','code','change', 'concat_color'))
m4=merge(m3,lu,by="concat_color")

lu = setNames(lu,c('column','code','change', 'concat_population'))
m5=merge(m4,lu,by="concat_population")

lu = setNames(lu,c('column','code','change', 'concat_habitat'))
m6=merge(m5,lu,by="concat_habitat")
  1. Now we drop up the unused fields and create a new subset.
m6 = setNames(m6,c('n','n','n','n','n','n','n','n','n','n','class','n','n','color','n','n','population','n','n','habitat'))
m7<-subset(m6, select=c(class, color, population, habitat ))