How to convert many words with no commas between them to a vector with a single algorithm?

49 views Asked by At

Let's say I have the following words (but thousands of them) and there are no commas between them :

Hello Hi How Hide Hold Hear

and I want to convert them into a vector called H_words

H_words = c("Hello", "Hi", "How", "Hide", "Hold", "Hear")

How can we make that with a single and simple algorithm ?

1

There are 1 answers

1
Konrad Rudolph On
words = "Hello, Hi, How, Hide, Hold, Hear"
H_words = strsplit(words, ", ")[[1L]]
H_words
# [1] "Hello" "Hi"    "How"   "Hide"  "Hold"  "Hear"