Re: [R] problem with putting objects in list

From: Rainer M Krug <rkrug_at_sun.ac.za>
Date: Wed 06 Sep 2006 - 14:04:06 GMT

Antonio, Fabio Di Narzo wrote:
> Use 'sapply' instead of 'lapply'. Type If I use sapply it seems to simplify / collapse to much.

>> ?lapply

> for details

> 
> Antonio, Fabio Di Narzo.
> University of Bologna, Italy
> 
> 2006/9/6, Rainer M Krug <rkrug@sun.ac.za>:

>> Hi
>>
>> I use the following code and it stores the results of density() in the
>> list dr:
>>
>> dens <- function(run) { density( positions$X[positions$run==run], bw=3,
>> cut=-2 ) }
>> dr <- lapply(1:5, dens)
>>
>> but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
>> works, but plot([1]) doesn't.
>>
>> Is there any way that I can store them in dr[i]?
>>
>> Thanks a lot,
>>
>> Rainer
>>
>>
>>
>> --
>> Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
>> Biology (UCT)
>>
>> Department of Conservation Ecology and Entomology
>> University of Stellenbosch
>> Matieland 7602
>> South Africa
>>
>> Tel: +27 - (0)72 808 2975 (w)
>> Fax: +27 - (0)21 808 3304
>> Cell: +27 - (0)83 9479 042
>>
>> email: RKrug@sun.ac.za
>> Rainer@krugs.de
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch 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.
>>
-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:		+27 - (0)72 808 2975 (w)
Fax:		+27 - (0)21 808 3304
Cell:		+27 - (0)83 9479 042

email:	RKrug@sun.ac.za
      	Rainer@krugs.de

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Thu Sep 07 01:16:19 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.