[R] building a list in loop

Fred J. phddas at yahoo.com
Sat Mar 27 17:19:20 CET 2004


--- Uwe Ligges <ligges at statistik.uni-dortmund.de>
wrote:
> Fred J. wrote:
> 
> > Hello
> > 
> > getdata <- function(p){
> > fname <- NULL; dl <- list()#build the sturcture
> >   builddl <- function(q,s){
> >    fname <<- c(fname,s) #where "s" is a string
> >    dl <<- list( dl, dt2)
> 
> "Fred J." alias "phddas", you are really not going
> to use <<- here, 
> please read the manuals.

thats what I do every time I think of asking a Q. I
sure could use some help in pointing out which manual
since there are few and which title/or sub-title if
you know off hand.

> 
> 
> >  }
> >  list(names = fname, data = dl)
> > }
> > data <- getdata("c:\somepath")
> 
> This won't work, please read the R for Windows FAQs.
> 
> 
> > 
> >>data
> > 
> > $names
> > [1] "fname"
> > 
> > $data
> > $data[[1]]  <--- since there is no [[1]] how can I
> > stop 
> 
> It's just a matter of printing the list, in one list
> elements are named, 
> in the other elements are unnamed.
> 
> 
> > list()      <--- this from happening? 
> 
> What are you going to stop???
> 
> I guess some kind souls on this list would be happy
> to help, but you 
> need to specify your problem precisely enough! In
> this case, I don't 
> understand your problem, and I even do not
> understand your question.
> 
> Let me cite the last line of all R-help messages:
> "PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html".

again, I would surely like to have some guide in HowTo
find the answer for a specific problem rather than get
it handed to me on a plate. that will payoff next for
next times.

many thanks

> 
> Uwe Ligges
> 
> 
> > $data[[2]]
> > ... lists all rows and cols here
> > 
> > thanks
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> >
>
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list