I have a large data.frame of character data that I want to convert based on what is commonly called a dictionary in other languages.
Currently I am going about it li
Using dplyr::recode:
library(dplyr) mutate_all(foo, funs(recode(., "AA" = "0101", "AC" = "0102", "AG" = "0103", .default = NA_character_))) # snp1 snp2 snp3 # 1 0101 0101 # 2 0103 # 3 0101 0103 # 4 0101 0101