[R] Minor warning about seq

Carl Witthoft carl at witthoft.com
Fri Dec 3 00:07:55 CET 2010


I believe the R intro manual and R-inferno have some pretty stern 
warnings about never using 'c' or 't' as variable names, for obvious 
reasons.

Similarly,  I nearly crushed some code once by writing a nice little 
function to find the mode of a data set and calling the function 
"mode()" .  (conflicts w/ an R builtin).  Ended up calling it 'smode' .

Carl


From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Wed, 01 Dec 2010 00:14:17 -0800 (PST)

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,
 >

Which leads us to another rule: never use a variable called "O". I 
remember this was a no-no even in my first Algol-course in 1967.



More information about the R-help mailing list