0

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 ?

Anas116
  • 797
  • 2
  • 9

1 Answers1

1
words = "Hello, Hi, How, Hide, Hold, Hear"
H_words = strsplit(words, ", ")[[1L]]
H_words
# [1] "Hello" "Hi"    "How"   "Hide"  "Hold"  "Hear"
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • yes thanks. but in another scenario let's say that there are no commas between the words. How can we handle this issue in that case ? – Anas116 Oct 06 '22 at 09:44