unlist(x)

r-help-boun...@r-project.org wrote on 08/10/2011 01:58:57 PM:

> [image removed] 
> 
> [R] convert 'list' to 'vector'?
> 
> Liviu Andronic 
> 
> to:
> 
> r-help@r-project.org Help
> 
> 08/10/2011 02:02 PM
> 
> Sent by:
> 
> r-help-boun...@r-project.org
> 
> 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
> 
> ______________________________________________
> 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.

        [[alternative HTML version deleted]]

______________________________________________
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