Re: [R] period in scale parameter of prcomp

From: William Dunlap <wdunlap_at_tibco.com>
Date: Fri, 13 May 2011 11:19:35 -0700

> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Greg Hirson
> Sent: Friday, May 13, 2011 10:58 AM
> To: R-help_at_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
> ghirson@ucdavis.edu
>
> Graduate Student
> Agricultural and Environmental Chemistry
>
> 1106 Robert Mondavi Institute North
> One Shields Avenue
> Davis, CA 95616
>
> ______________________________________________
> R-help_at_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_at_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. Received on Fri 13 May 2011 - 18:23:06 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 May 2011 - 19:20:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive