Thanks, everyone, I will definitely avoid it.  Is there any tips on naming
variables?  I've seen the Google R style guider and Hadley R style guide.

For example, I want to use pie_t, to denote stationary distribution pie at
time t.  Both "pi" and "pie" are function names themselves.

Mike

On Fri, Mar 1, 2013 at 8:12 PM, William Dunlap <wdun...@tibco.com> wrote:

> > See fortune("dog").
> To wit:
>   "Firstly, don't call your matrix 'matrix'. Would you call your dog
> 'dog'? Anyway, it might clash with the function 'matrix'"
>
> I once had a cat named "kitty" and she never had a problem with it.
>
> Clashes between non-functions and functions that cause problems are not
> that common.  With 4000 packages, each with a number of functions, it is
> hard to avoid using a name that someone has used for a function.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -----Original Message-----
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of Rolf Turner
> > Sent: Saturday, March 02, 2013 5:01 AM
> > To: Sarah Goslee
> > Cc: r-help
> > Subject: Re: [R] using reserved words in R, and reuse variable names in
> different
> > functions
> >
> > On 03/02/2013 01:12 PM, Sarah Goslee wrote:
> > > On Fri, Mar 1, 2013 at 7:06 PM, C W <tmrs...@gmail.com> wrote:
> > >> Thanks, that was just an example I came up with.  I was just curious
> if
> > >> using same variable names in different functions would cause problems.
> > > No. The environment of a function is independent of other functions.
> > >
> > >>   Especially with reserved words.
> > > Yes. Using reserved words can cause all kinds of subtle problems.
> Avoid it.
> > >
> >
> > Very sound advice.  But it should be noted that "t", "c", and "matrix"
> > to which
> > the OP referred are *not* technically reserved words.  Nonetheless their
> use
> > as names of user-defined objects should be eschewed.  See fortune("dog").
> >
> > You *can't* actually assign values to reserved words.  E.g.
> >
> >      TRUE <- 42
> >
> > throws an error.  (Whereas matrix <- 42, bad form though it may be,
> > does not throw an error.)
> >
> >      cheers,
> >
> >          Rolf Turner
> >
> > ______________________________________________
> > 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to