[R] I might be dumb : a simple question about "foreach"

Olivier ETERRADOSSI Olivier.Eterradossi at ema.fr
Mon Jul 20 14:48:30 CEST 2009


Hi list,
My attention was drawn to the foreach package by recent posts...I 
decided to have a look...
I'm using R.2.9.1 on Windows, I have downloaded the foreach package 
today (v 1.2.1), together with iterators (v. 1.0.1) and codetools (v.0.2-2).
Full of hope I try the most simple thing of all out of the package 
vignette :
>  x <- foreach(i = 1:3) %do% sqrt(i)
and get :
> Erreur dans sqrt(i) : indice hors limites ( i.e. "error in sqrt(i) : 
> index out of bounds")
but when trying :

> x<-foreach(i = 1:3) %do% print(sqrt(i))
I get :

> [1] 1
> [1] 1.414214
> [1] 1.732051
> Erreur dans print(sqrt(i)) : indice hors limites
Probably I didn't drink enough coffee this morning and I'm still asleep 
: it is obvious that  I miss a point... but I am unable to see which one.
Any help appreciated ! Many thanks, and very best regards Olivier

-- 
Olivier ETERRADOSSI
Maître-Assistant
CMGD / Equipe "Propriétés Psycho-Sensorielles des Matériaux"
Ecole des Mines d'Alès
Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
tel std: +33 (0)5.59.30.54.25
tel direct: +33 (0)5.59.30.90.35 
fax: +33 (0)5.59.30.63.68
http://www.ema.fr




More information about the R-help mailing list