[R] differences in using source() or console

Duncan Murdoch murdoch at stats.uwo.ca
Thu Dec 6 19:11:15 CET 2007


On 12/6/2007 8:01 AM, vito muggeo wrote:
> Dear all,
> Is there *any* reason explaining what I describe below?

Probably, but you're unlikely to get a correct explanation if you don't 
give us code to reproduce the problem.

 From the look of things, your real example is quite complex, which is 
probably why you didn't post it.  But the very act of simplifying it to 
something that is reasonable to post is quite likely to reveal to you 
what the problem is.

Duncan Murdoch

> I have the following line
> 
> myfun(x)
> 
> If I type them directly in R (or copy/past), it works..
> 
> However if I type in R 2.6.1
> 
>  > source("code.R") ##code.R includes the above line
> Error in inherits(x, "data.frame") : object "d" not found
> 
> namely myfun() does not work correctly.
> In particular the non-working line inside myfun() is
> 
> update(eval(x$call$obj), data=d) #d is created in myfun()
> 
> My question is: why the problem occurs just via source()ing???
> 
> many thanks,
> vito
> 
> 
> ====================================
> Vito M.R. Muggeo
> Dip.to Sc Statist e Matem `Vianelli'
> Università di Palermo
> viale delle Scienze, edificio 13
> 90128 Palermo - ITALY
> tel: 091 6626240
> fax: 091 485726/485612
> 
> ______________________________________________
> 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.



More information about the R-help mailing list