Re: [R] Replace any values in a data frame based on another data frame

2016-07-30 Thread Jeff Newmiller
Your use of HTML email corrupted your example slightly, but I was able to fix it. Please follow the Posting Guide and set your emails to Plain Text mode when posting to this mailing list in the future. Here is one way: # you have to be careful about mucking with factors # convert columns to fa

Re: [R] Replace any values in a data frame based on another data frame

2016-07-30 Thread Bert Gunter
Marine: Thanks for the reproducible example. I would not have fooled with this otherwise! 1. First note that your specification that you wish to replace only those values in col3 and col4 of df1 that don't match with those of df2 is irrelevant: if you replace those that do match you don't change

[R] Replace any values in a data frame based on another data frame

2016-07-30 Thread Marine Regis
Hello, I have two data frames with different sizes but with the same number of columns. > df1 <- data.frame(col1 = c(1:6), col2 = c(rep("a", 3), rep("b", 3)), col3 = > c(rep("AA", 2), rep("BB", 2), rep("CC", 2)), col4=c(1,8,6,9,7,6)) > df1 col1 col2 col3 col4 11a AA1 22