In R I have a string like this:
'hello'
How do I convert it to a character vector like that:
[1] "h" "e" "l" "l" "o"
In R I have a string like this:
'hello'
How do I convert it to a character vector like that:
[1] "h" "e" "l" "l" "o"
With stringr
:
stringr::str_split("hello","")[[1]]
[1] "h" "e" "l" "l" "o"
Found another possible solution, although this is probably the worst approach:
substring("hello", seq(1,nchar("hello")), seq(1,nchar("hello")))
[1] "h" "e" "l" "l" "o"