1

I am trying to split a string let's say "abcde" into a vector of "a","b","c","d","e"

How can i do that?

i have tried strsplit but that makes it into 1 element

a=unlist(strsplit("abcde", split=" "))
  • You need to split on an empty string: `unlist(strsplit("abcde", split=""))`; from `?strsplit`: *If empty matches occur, in particular if ‘split’ has length 0, ‘x’ is split into single characters*. – Maurits Evers Dec 11 '18 at 23:34

1 Answers1

0

We need the split = ""

unlist(strsplit('abcde', ''))
akrun
  • 874,273
  • 37
  • 540
  • 662