Combine two dataframe columns in R -
this question has answer here:
- paste elements of 2 columns [duplicate] 2 answers
suppose have dataframe such as:
b c
a
b b
d e
and want create new column in dataframe b , c combined (call d).
a b c d
aa
b b bb
d e ea
you can use paste
.
df1$d <- do.call(paste0, df1[c('b', 'c')])
or
df1 <- transform(df1, d= paste0(b,c))
Comments
Post a Comment