Replace values in a dataframe based on lookup table
You posted an approach in your question which was not bad. Here’s a smiliar approach: new <- df # create a copy of df # using lapply, loop over columns and match values to the look up table. store in “new”. new[] <- lapply(df, function(x) look$class[match(x, look$pet)]) An alternative approach which will be faster is: … Read more