[ESS] Developing R packages under ESS

Peter Meilstrup peter@me||@trup @end|ng |rom gm@||@com
Thu Mar 8 02:50:16 CET 2018


The devtools package makes it all lot less painful, so start by installing that. https://cran.r-project.org/web/packages/devtools/README.html <https://cran.r-project.org/web/packages/devtools/README.html>

ESS has a minor mode ess-r-package-mode that will drive devtools commands, for instance ess-r-devtools-load-package (C-c C-w C-l) will recompile and reload all the code in your package while working around locked namespaces.

(in an R buffer in a package source directory)
M-x ess-r-package-mode
C-c C-w C-l

When activated in a R buffer, ess-r-package-mode makes it so that evaluating definitions in that a buffer goes into the package namespace (I usually just C-(c-w-l) so I’m not super clear on what’s going on there )

Peter

> On Mar 7, 2018, at 17:28, Boylan, Ross <Ross.Boylan using ucsf.edu> wrote:
> 
> Can anyone suggest to me a good way to develop R packages with ESS?  "good" here means that I  can debug the code and make changes to the code without rebuilding the whole package.
> 
> So far I've tried a bunch of different approaches, but none has quite worked.
> 
> 1. When I had an old (or even new) version of the package in the standard load paths I tended to get "namespace is locked" errors when I modified the code and attempted to read it in.  So I deleted the installation in the standard path.
> 
> 2. Wrote a script that sourced all the .R files.  But when I change them and reload in ESS I get the error "unable to load <mylibrary>", even if I do C-c C-t C-s to turn off the namespace.  I suspected the problem might have been from evaluating vignette code in an .rnw file, but even if I copied and pasted it into the the main *R* buffer I still get the problem:
> Loading required package: LazarSim
> Error in .requirePackage(package) (from SimParameters.R#35) :                                                                                                                                
>   unable to find required package ‘LazarSim’
> In addition: Warning message:
> In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
>   there is no package called ‘LazarSim’
> BTW, that error happened after I attempted to execute some code from the package, not when I issued any load/library/require type command.
> 
> R is running in the directory above the package directory.
> Grep confirms my recollection that I don't have code that does require().
> Maybe R overrides the basic code for sourcing files?  My test file uses source() to load the source files, which are in the package directory.
> 
> Thanks for any help.
> Ross
> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help


	[[alternative HTML version deleted]]




More information about the ESS-help mailing list