0

I'd like to split a character vector so that additional members are added to the length of the vector.

> va <- c("a", "b", "c;d;e")
[1] "a"     "b"     "c;d;e"
> vb <- strsplit(va, ";")
[[1]]
[1] "a"

[[2]]
[1] "b"

[[3]]
[1] "c" "d" "e"

Can can I get vb vector in the same format as va vector so that I get 1-dimensional, 5 member vector in vb as such?

[1] "a"     "b"     "c"      "d"       "e"

Appreciate the help.

Jay
  • 741
  • 10
  • 26

2 Answers2

3

One possibility:

unlist(vb)
# [1] "a" "b" "c" "d" "e"
Henrik
  • 65,555
  • 14
  • 143
  • 159
2

Or

scan(text=va, sep=";",what="")
#Read 5 items
# [1] "a" "b" "c" "d" "e"
akrun
  • 874,273
  • 37
  • 540
  • 662