[R] the difference between temp and .temp

jim holtman jholtman at gmail.com
Fri Oct 26 02:01:36 CEST 2007


It is a holdover from my past when one of the languages that I used to
use had that convention for 'local' variables in a block of code.  I
was used to the convention of being able to define a variable that was
only known in the enclosing block.  By convention I try to keep those
objects active for only a few statements and not use them to carry
values over a long block of code.  I also use it to break up a long,
complex statement into several steps so I can remember what is going
on.  I also tend to use them within 'applys' since I know they will
disappear after the call.

On 10/25/07, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> On 26/10/2007, at 11:44 AM, Tim Calkins wrote:
>
> > Hi everyone -
> >
> > This came up within the last day -- Jim's response to Deepankar is
> > pasted below.
>
>        (but snipped out of this response).
>
> > There are probably lots of reasons, but what is the advantage to using
> > .temp over, say, temp?
> >
> > I often find myself writing temporary objects -- should I use the .
> > preface?  What would be the advantages to doing so?
> >
> > Thanks in advance for what will surely be a collection of illuminating
> > responses.
>
> The difference is that you see ``temp'' when you do an ls() of your
> workspace, and you don't see ``.temp'' --- it's hidden.  Unless you ask
> particularly nicely!
>
> The advantage of using .temp is that you can't see it (so it doesn't
> clutter things up).
>
> The ***dis**advantage of using .temp is that you can't see it! :-)
>
> I guess the rationale for using .temp is the presumption that if you
> can't see it
> you don't really want it.  I.e. overwriting something called .temp is
> unlikely to lose
> you an object that you desperately wanted to keep.  If you were
> passionately fond
> of the contents of .temp, you would've named the object in such a way
> that you
> could look at it from time to time without having to make a special
> effort (having to set
> all.names=TRUE).
>
> OTOH something called temp is unlikely to be something of which you are
> passionately fond anyhow.
>
>                        cheers,
>
>                                Rolf Turner
>
> ######################################################################
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> ______________________________________________
> 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list