[R] decomposing a single intact vector
Rui Barradas
ruipbarradas at sapo.pt
Thu Jun 28 12:58:09 CEST 2012
Hello,
Try
x <- "(O, O, O, H, L, O, O, O, O)"
strsplit(gsub("\\(|\\)|[[:blank:]]", "", x), ",")
Note that the result is a list, not a vector. You can then use `[[` or
unlist().
Hope this helps,
Rui Barradas
Em 28-06-2012 11:42, Jessy escreveu:
> Dear all,
>
> I have a vector of length 1 but within this vector there are 9 elements
>> vectorNOcorrection
> [1] "(O, O, O, H, L, O, O, O, O)"
> can someone help me with how I can have it as with 9 element separated
> such that it will have length 9 as "O", "O"," O", "H","L", "O", "O", "O",
> "O"
>
> Kind regards,
> Jessy
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list