Check function unlist().

Best,
Dimitris


On 8/10/2011 8:58 PM, Liviu Andronic wrote:
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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

______________________________________________
R-help@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.

Reply via email to