[R] how to initial a list to store data result?

William Dunlap wdunlap at tibco.com
Tue Jun 22 01:26:35 CEST 2010


Use
  result <- vector("list", n)
to make a list of length n, all of whose
components are NULL.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Peter Langfelder
> Sent: Monday, June 21, 2010 4:23 PM
> To: song song
> Cc: r-help at r-project.org
> Subject: Re: [R] how to initial a list to store data result?
> 
> On Mon, Jun 21, 2010 at 4:18 PM, song song 
> <rprojecthelp at gmail.com> wrote:
> > May I ask how to initialize a list?
> >
> > usually I will use " result=list(0) "  to do this. is this right?
> 
> It works, but it is cleaner to use
> 
> results=list()
> 
> The difference is that list(0) will have one component that contains
> the number zero, whereas list() will simply initialize an empty list
> (no components).
> 
> Peter
> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list