Reputation: 527
I have two dataframes:
df1 = data.frame(text = c("text1","text2"), id=c(1,2))
df2 = data.frame(text = c("text3","text4"), id=c(3,4))
I would like to create a new column from the two text columns However using this it gives two columns
dftext <- merge(df1$text,df2$text)
Expected data output:
dftext
text1
text2
text3
text4
What is the correct option?
Upvotes: 1
Views: 25
Reputation: 99371
You have plenty of options here, the easiest and most appropriate being rbind()
.
rbind(df1["text"], df2["text"])
# text
# 1 text1
# 2 text2
# 3 text3
# 4 text4
or
rbind(df1, df2)["text"]
# text
# 1 text1
# 2 text2
# 3 text3
# 4 text4
Upvotes: 1