Reputation: 5345
I want to append to a data.frame the same string.
> df1 <- data.frame(pt1="a", pt2="b", row.names=1)
> df1
pt1 pt2
1 a b
As a result I would like to have:
pt1 pt2
1 Add this string a Add this string b
Upvotes: 4
Views: 7668
Reputation: 886938
We can use lapply
df1[] <- lapply(df1, function(x) paste('Add this string', x))
Or use Map
df1[] <- Map(paste, 'Add this string', df1)
Or
library(dplyr)
df1 %>%
mutate_each(funs(paste('Add this string', .)))
Upvotes: 7