Perhaps this is what was intended?

sims <- list(length=100)

do.call(seq, sims)

seq by itself does not expect a list, but do.call() can create the appropriate call if a list is what you want to pass to the function.

Hope this helps,

baptiste

On 5 Feb 2009, at 19:46, Uwe Ligges wrote:



Uwe Ligges wrote:


Kjetil Halvorsen wrote:
This surprised me:

reps <- 100
sims <- list(length=reps)
sims
$length
[1] 100

for(i in seq(along=sims))print(i)
[1] 1

This is R 2.8.1.


What is surprising?

sims is now a list that contains 1 element called "length" with a
numeric value of 100.
Then seq(along=sims) is exactly 1, because sims has length 1.
Hence i is printed once (1 iteration of the loop) and is 1 in the first
(and only) iteration.

Uwe

I should have added that you probably want

sims <- vector(mode="list", length=100)

Uwe




Kjetil

   [[alternative HTML version deleted]]

______________________________________________
R-help@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.


______________________________________________
R-help@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.

_____________________________

Baptiste AuguiƩ

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

______________________________________________
R-help@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.

Reply via email to