[R] Are loops handled differently in newer versions of R?
Michael Bibo
michael_bibo at health.qld.gov.au
Wed Mar 17 04:51:05 CET 2010
Michael Rennie <mdrennie <at> gmail.com> writes:
>
>
> Hi gang,
>
> I'm perplexed- I have some code that uses for() loops that works fine in
> R version 2.8 on my mac, worked fine in version 2.8 on my old windows
> machine, but doesn't work in version 2.10 on windows.
>
> The loop implements a function over a data frame (code is included below).
>
> In Mac (running version 2.8), the results of the loop are what I expect:
>
> > p_unadj
> [1] 0.034939481 0.015743706 0.089287030 0.001098538 0.039290594
Hi Michael,
I'm not sure what the mac is doing, but if you change the syntax of the loop as
follows it gives the same answers:
> for ( i in 1:length(lab8.dat[,1]) )
+ p_unadj[i]<-calc.prob.t(lab8.dat[i,2], lab8.dat[i,3])
> p_unadj
[1] 0.034939481 0.015743706 0.089287030 0.001098538 0.039290594
Hope this helps,
Michael Bibo,
Queensland Health
More information about the R-help
mailing list