Message-ID: <498B41D3.30002@statistik.tu-dortmund.de>
Date: 2009-02-05T19:45:23Z
From: Uwe Ligges
Subject: seq(along= surprise
In-Reply-To: <556e90a80902051125g155919c5sdf6788ec3d76b407@mail.gmail.com>
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
> Kjetil
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.