I've recently begun analyzing a data set and need to tabulate how many occurences of prison misconducts there are in it, by administration, by individual, and so on. The misconducts are coded by number (e.g. 1= Assault; 5= robbery; 34= possession of contraband; etc.) in the data set, and I have a code book in excel that lists out all 51 types of misconduct by their numerical code and their text-based description. I'm hoping there is a way to import this code book into RStudio and have it automatically match the numbers up and put label the rows in my table with them.
Basically, I have written the code below to give me a frequency count table of the number of misconducts, but I also want to have their text string labels in there as another column too. Only, I don't want to have to re-write them all myself. Anyone have any suggestions?
XXXX_MisconductTable=MisconductDataset%>% filter(offeringadmin==-1)%>% count(Misconducts)
1 0 183
2 1 127
3 3 1
4 4 2
5 8 1
6 9 5