The best way to attach labels to numeric variables

Using the forcats package you can get the unique factor levels for a set of observations by converting to factor after you've read in the data with as_factor().

Once you've read your data in, you can recode the factors with their labels, if you so choose (see thread below).

Another option would be to use a "lookup table," which is nicely described in this thread (although, personally, I tend not to do that—I don't actually have a good reason, though):

2 Likes