[R] And about sum() ...Re: Minor warning about seq

David Winsemius dwinsemius at comcast.net
Tue Nov 30 19:59:38 CET 2010

On Nov 30, 2010, at 1:49 PM, Prof. John C Nash wrote:

> I spent more time than I should have debugging a script because I  
> wanted
>   x<-seq(0,100)*0.1
> but typed
>   x<-seq(O:100)*0.1
> seq(0:100) yields 1 to 101,
> Clearly my own brain to fingers fumble, but possibly one others may  
> want to avoid it.

I discovered some flakey code (that ran without syntactic error and  
sometimes even without semantic error) that was intended to add a risk  
estimate from a number of completed years of exposure to a fractional  

sum(q[1:4] + frac*q[5])

... looked to my brain as sensible, but was actually adding the  
fractional risk to each of the q[1:4]'s before summation occurred.  
(Should have been ...

sum(q[1:4] , frac*q[5])

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list