gistlib
# Sample data df <- data.frame(col1 = c("123", "456", "789"), col2 = c("123", "555", "789")) # Replacing values in col2 with col1 where they match df$col2 <- ifelse(df$col1 == df$col2, df$col1, df$col2) df 224 chars8 lines
# Sample data df <- data.frame(col1 = c("123", "456", "789"), col2 = c("123", "555", "789")) # Replacing values in col2 with col1 where they match df$col2 <- ifelse(df$col1 == df$col2, df$col1, df$col2) df
gistlibby LogSnag