s-news
[Top] [All Lists]

Re: [S] Changing a list to a vector

To: donald@portal.ca (Alan Donald)
Subject: Re: [S] Changing a list to a vector
From: Bill Venables <wvenable@attunga.stats.adelaide.edu.au>
Date: Wed, 20 May 1998 08:39:00 +0930
Cc: s-news@wubios.wustl.edu
In-reply-to: <199805191704.KAA28985@shell.portal.ca>
References: <199805191704.KAA28985@shell.portal.ca>
Sender: owner-s-news@wubios.wustl.edu
Alan Donald writes:
 > This is rather a simple question that I remember running into
 > about a year ago and solving -- but I cannot remember how I
 > did it.
 > 
 > I have a list whose components are numeric vectors of various
 > lengths.  What I want to do is to strip the "list" structure
 > from the object so that I get a vector consisting of all the
 > components glued together.  This is part of a program, so I
 > could -- I guess -- write a little program that trudges its
 > way through the list tacking vectors on to the end of a long
 > train of numbers.  But I think there is a function in Splus
 > that will do this for me quickly.  Searches through the Splus
 > 3.3 and 4 help files and manuals have turned up nothing.  Must
 > be looking under the wrong word.

The "I could kick myself" answer is, of course,

> one.big.vector <- unlist(list.of.vectors). 

It then occurred to me that there is another answer almost as
simple and somewhat more instructive:

> one.big.vector <- do.call("c", list.of.vectors)

Bill
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>