[Rd] New behavior when running script in package directory?

Jan van der Laan rhe|p @end|ng |rom eoo@@dd@@n|
Wed Jun 21 08:17:26 CEST 2023


Could there be a .Rprofile or .RData file in the directory where you 
start R? These are run/loaded when you start R when present (with the 
default arguments when starting R).

HTH,
Jan



On 20-06-2023 23:38, Dominick Samperi wrote:
> When I run a script foo.R containing some trivial code in my home
> directory, via Emacs/ESS, everything works as expected: R
> starts, and a setwd() command to set the working directory is
> run automatically before the code in the script is run.
> 
> But if I copy foo.R to some package/R directory strange
> things happen. When I use Emacs/ESS to run the script
> in its new location, R starts, and setwd() is called to set
> the working directory, but then one or more libraries that the
> package depends on are loaded, even though I am using no
> libraries in foo.R.
> 
> Now consider foo.R that contains the following trivial code:
> secsToRDateTime <- function(secs) {
>    day2sec <- 60*60*24
>    days <- secs/day2sec
> }
> 
> When I try to run this from package/R I get...
> 
> Error in ss(file, echo = visibly, local = local, print.eval = output,  :
>    /tmp/gpstime.R!CuSewT:2:0: unexpected end of input
> 1: secsToRDateTime <- function(secs) {
>     ^
> 
> As I said, there are no problems when the script is run from my
> home directory. This suggests that test scripts can no longer be
> tested in a package's R directory?
> 
> Is this true?
> 
> Thanks,
> Dominick
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list