> -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Hirson > Sent: Friday, May 13, 2011 10:58 AM > To: R-help@r-project.org > Subject: [R] period in scale parameter of prcomp > > Hi all, > > Looking at the help file for prcomp and the code in > stats:::prcomp.default, the scale parameter for the default S3 method > has a trailing period: it written as > > scale. > > I assume there is a reason for it (backwards compatibility with S was > suggested) but I thought I'd ask.
In ancient versions of S you would get an error running a function like f <- function(x, plot=TRUE) { if (plot) plot(x, x^2) } because when it evaluated plot(x,x^2) the object called 'plot' was a logical vector, not a function. The usual workaround was to call the argument 'plot.', as in f <- function(x, plot.=TRUE) { if (plot.) plot(x, x^2) } You could still call it as f(x, plot=FALSE) since tag abbreviations are allowed in function calls. Now the 'plot' in the function call 'plot(x,x^2)' is looked up differently than the 'plot' in 'if(plot)': the former search keeps going until it finds a function object. Hence the dot is no longer needed, although it might make you think about how 'plot' can mean two different things in the same environment. Older functions still have this dot because there is no good reason to change them and changing them can break old code. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > > Thanks, > Greg > > -- > Greg Hirson > ghir...@ucdavis.edu > > Graduate Student > Agricultural and Environmental Chemistry > > 1106 Robert Mondavi Institute North > One Shields Avenue > Davis, CA 95616 > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.