maintain.packages {mvbutils} | R Documentation |
Set up task package(s) for editing and/or live-editing. You need to be cd
ed into the task above your source-task. maintain.packages
must be called before loading the package via library
or require
.
# E.g. in your .First, after library( mvbutils), or in a '.First.task' above yr source task maintain.packages(..., character.only = FALSE)
... |
names of your packages, unquoted unless character.only is TRUE. Package names must correspond to subtasks of the current task. |
character.only |
see above |
maintain.packages( mypack)
loads a copy of your source-task package "mypack" (as stored in its ".RData" file) into a variable ..mypack
in the "mvb.session.info" environment. You don't normally need to know this, because normally you'd modify/create functions in the package via fixr
or fixr(..., pkg="mypack")
. However, you can directly modify the contents of ..mypack
. If you do, then remember to use <<-
, e.g. ..mypack$newfun <<- function( x) whatever
, rather than <-
; otherwise, a local copy of ..mypack
will be created in the current task. If that does happen, just rm
it; the local copy and the master copy in "mvb.session.info" both point to the same thing, and modifying one implies modifying the other, so that deleting the local copy won't affect the master.
If you use mvbutils
to pre-build your package, then your package must exist as a task in the cd
hierarchy. This means you can in theory cd
to its workspace. However, thanks to maintain.packages
, there is no compelling need to have the package/task at the top of the search path. In fact, I don't really recommend cd
ing to a loaded package, because of the potential for confusion; there are then 4 potentially -different versions of objects floating around in R! Nevertheless, if you really want to then it should be possible to cd
to a package-as-task; this might be useful if you want to add several new objects to the package without having to create & move them.
If do you cd
to a package/task that is already loaded under maintain.packages
, then the loaded version of the package is "frozen" until you cd
back up from the package/task. All fixr
edit operations on objects in the package are redirected to the task version, i.e. the one highest on the search path. pre.install
and then patch.installed
will still work, since they operate on the disk image. When you cd
back up, the task is updated on disk (as cd
always does), and the maintained-package version is reloaded from disk, and all fixr
edits are redirected to the maintained-package version.
fixr
, pre.install
, patch.installed
# whatever they are... ## Not run: # In your .First: library( mvbutils) maintain.packages( myfirstpack, mysecondpack, mythirdpack) # or... live.edit.list <- c( 'myfirstpack', 'mysecondpack', 'mythirdpack') maintain.packages( live.edit.list, character.only=TRUE) library( myfirstpack) # etc ## End(Not run)