Very simple question, but am struggling to find the solution.
Want to go from this:
a = c("the sky is color", "the color dog", "grass is color")
b = c("blue","brown","green")
df = data.frame(a,b)
To this:
a = c("the sky is color", "the color dog", "grass is color")
b = c("blue","brown","green")
c = c("the sky is blue", "the brown dog", "grass is green")
df = data.frame(a,b,c)
Tried using gsub:
df$d <- gsub('color', df$b, df$a)
But received this error message:
argument 'replacement' has length > 1 and only the first element will be used
Will the solution also work for integers? Thank you!