I see. I am using RStudio.

Thanks,
Gang


2013/8/16 William Dunlap <wdun...@tibco.com>

>  Are you using a GUI like RStudio to run R?  If it, it may be looking****
>
> at the values of things after each command to update its workspace****
>
> window, and the looking will trigger the delayed assignments.****
>
> ** **
>
> (I cannot reproduce what you show using command line R on Linux.)****
>
> ** **
>
> Bill Dunlap****
>
> Spotfire, TIBCO Software****
>
> wdunlap tibco.com****
>
> ** **
>
> *From:* Gang Peng [mailto:michael.gang.p...@gmail.com]
> *Sent:* Friday, August 16, 2013 1:55 PM
> *To:* William Dunlap
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] A question about using delayedAssign****
>
> ** **
>
> Hi Bill,****
>
> Thanks. According to the output, the assignment was triggered immediately
> after 'delayedAssign'. So strange.
>
> > msg <- "old"
> > delayedAssign("x", { cat("Assigning 'msg' to 'x' now\n") ; msg })
> > msg <- "new!"
> > x
> Assigning 'msg' to 'x' now
> [1] "new!"
> > msg <- "old"
> > delayedAssign("x", { cat("Assigning 'msg' to 'x' now\n") ; msg })
> Assigning 'msg' to 'x' now
> > msg <- "new!"
> > x
> [1] "old"****
>
> Best,
> Gang****
>
> ** **
>
> 2013/8/16 William Dunlap <wdun...@tibco.com>****
>
> Change
>    delayedAssign("x", msg)
> to
>    delayedAssign("x", { cat("Assigning 'msg' to 'x' now\n") ; msg })
> and you will see the message when the delayed assignment is triggered.
> You could add print(sys.calls()) to that to see the call stack if it isn't
> obvious.
>
> > msg <- "old"
> > delayedAssign("x", { cat("Assigning 'msg' to 'x' now\n") ;
> print(sys.calls()) ; msg })
> > f <- function(p) paste(x, p)
> > f("qwerty")
> Assigning 'msg' to 'x' now
> [[1]]
> f("qwerty")
>
> [[2]]
> paste(x, p)
>
> [[3]]
> print(sys.calls())
>
> [1] "old qwerty"
> > x
> [1] "old"
>
>
> 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 Gang Peng
> > Sent: Wednesday, August 14, 2013 6:12 PM
> > To: r-help@r-project.org
> > Subject: [R] A question about using delayedAssign
> >
> > I run the examples in delayedAssign:
> >
> > msg <- "old"
> > delayedAssign("x", msg)
> > msg <- "new!"
> > x
> >
> > If I run these four commands together, x is "new". If I run the first two
> > commands first and then run the last two commands, x is "old".
> >
> > I just cannot figure out why.
> >
> > Thanks.
> > Gang
> >****
>
> >       [[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.****
>
> ** **
>

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