[R] Bind field of a list
David Winsemius
dwinsemius at comcast.net
Fri Feb 19 16:09:38 CET 2010
On Feb 19, 2010, at 9:49 AM, statquant wrote:
>
> Hello,
> Thank you but I think not what I would like to get as an answer is
> the list
> ("x","v","n","m") + what you gave me could work for 2 fields but if
> I have
> 200...
>
>
> What I want is a vectorize way to do
> bindlists <- function(x){
> output = c();
> for (i in 1:length(x))
> {
> output = c(output,x[[i]])
> }
> return(output)
> }
Instead try:
c( sapply(test, "[") )
The inner (implicit) loop gets you a matrix and the outer c() turns it
into the requested vector. You could have coerced the matrix to vector
with as.vector, too.
>
> Regards
> --
> View this message in context: http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list