Learn R Programming

mvbutils (version 2.5.0)

maintain.packages: Set up task package for live editing

Description

Set up task package(s) for editing and/or live-editing. You need to be cded into the task above your source-task. maintain.packages must be called before loading the package via library or require.

Usage

# E.g. in your .First, after library( mvbutils), or in a '.First.task' above yr source task
maintain.packages(..., character.only = FALSE)

Arguments

...
names of your packages, unquoted unless character.only is TRUE. Package names must correspond to subtasks of the current task.
character.only
see above

Maintained packages as tasks

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 cding 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.

Details

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 <<-< code="">, e.g. ..mypack$newfun <<- function(="" x)="" whatever<="" code="">, 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.

See Also

fixr, pre.install, patch.installed

Examples

Run this code
# whatever they are...
# 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

Run the code above in your browser using DataLab