Turn column of df into a string?

mydf <- data.frame("sample"=c("blue","red","yellow","green"))

mydf 

  sample
1   blue
2    red
3 yellow
4  green

How can I make one string out of this with "OR" in between each entry, like this:

"blue OR red OR yellow OR green" ?

Do this:

paste(mydf[["sample"]], collapse=" OR ")
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.