[R] convert 'list' to 'vector'?
Liviu Andronic
landronimirc at gmail.com
Wed Aug 10 20:58:57 CEST 2011
Dear all
How does one convert a "non-symmetric" list to a vector? See below:
> x <- list()
> x[[1]] <- letters[1:5]
> x[[2]] <- letters[6:10]
> x[[3]] <- letters[11:12]
> x
[[1]]
[1] "a" "b" "c" "d" "e"
[[2]]
[1] "f" "g" "h" "i" "j"
[[3]]
[1] "k" "l"
> paste(x)
[1] "c(\"a\", \"b\", \"c\", \"d\", \"e\")" "c(\"f\", \"g\", \"h\",
\"i\", \"j\")"
[3] "c(\"k\", \"l\")"
> as.vector(x)
[[1]]
[1] "a" "b" "c" "d" "e"
[[2]]
[1] "f" "g" "h" "i" "j"
[[3]]
[1] "k" "l"
> simplify2array(x)
[[1]]
[1] "a" "b" "c" "d" "e"
[[2]]
[1] "f" "g" "h" "i" "j"
[[3]]
[1] "k" "l"
What I would need to get instead is:
> letters[1:12]
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l"
Any ideas? Regards
Liviu
--
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
More information about the R-help
mailing list