installFromSFiles
installs S-PLUS
objects from source files into a package while running S-PLUS.
installFromSFiles(files, where, clean.first=FALSE, sourcedir, extensions, verbose=TRUE) installFromDataFiles(files, where, clean.first = FALSE, sourcedir, extensions, verbose=TRUE) redirectGlobalAssignments(expr, where, enter.expression=TRUE)
installFromSFiles
will temporarily
override the read-only status assigned by the
library()
command.
parse
.
installFromSFiles
, can be any of the following:
S, R, ssc, SSC, q
installFromDataFiles
, can be any of the following:
csv, CSV, tab, TAB, txt, TXT, S, R, ssc, SSC, q, rda, rdata, RData
TRUE
, provides detailed information about the installation.
redirectGlobalAssignments
to indicate if objects of mode expression should be searched for
assignments such as
<-
,
assign
, and
setMethod
.
The default value is
TRUE
.
installFromSFiles
is the useless value
vector("missing",0)
.
The function
redirectGlobalAssignments
returns an expression similar to the input expression but with
where=where
in all assignments.
The package directory specified by the
where=
argument must already exist. It can be attached or unattached.
Source files can be created using S-PLUS functions such as
dump()
,
dumpMethods()
,
and
package.skeleton()
Some assignments, such as
a<-b<-value
and
x$name<-value
,
are hard to handle and may cause errors.
The function
installFromDataFiles
reads the data
files in a package and stores them in its
.Data
directory.
You can pass in either a list of files or a source directory and the names of the
relevant file extensions in the source directory.
The function
redirectGlobalAssignments
is called by
installFromSFiles
to change
global assignments in an expression to use
where=where
instead of the implicit where=1 or an explicit setting of
where
in assignments.
This function is primarily for internal use.
# Create an attachable directory, then install objects from source files testdir <- tempfile() createChapter(testdir) # put some assignments into a source file file2=file.path(testdir, "newFunc2.q") cat(c("{ newFunc2<-function(x)x+1", "setGeneric(\"newFunc2\", function(x)standardGeneric(\"newFunc2\"), where=\"DEST\")", "setMethod(\"newFunc2\", \"character\", function(x)toupper(x)) }") , file=file2, fill=T) # install from the source file and verify installFromSFiles(files=file2, where=testdir) attach(testdir) cat(newFunc2("a"),newFunc2(12), sep=":", fill=T) rmdir(testdir)
# Create a new package, then install objects from new source files testdir <- tempfile() mkdir(testdir) newFunc0 <- function(x) newFunc1(x) newFunc1 <- function(x) log(x) # create a new package library(pkgutils) pkgname <- "testPackage" package.skeleton(name=pkgname, list=c("newFunc0","newFunc1"), path=testdir, force=FALSE) pkgdir <- file.path(testdir, pkgname) createChapter(pkgdir) library(eval(pkgname), lib.loc=testdir) rm("newFunc0","newFunc1") # install the newly created source file(s) installFromSFiles(files=list.files(file.path(packagedir,"R"), full.names=T), where=pkgname) # verify that everything is there objects(where=pkgname) newFunc1(exp(10)) detach(pkgname) rmdir(testdir)
# Returns the expression modified so that all assignments # are to the "MY_PACKAGE" directory. z <- redirectGlobalAssignments(where="MY_PACKAGE", Quote( { f<-function(x)x+1 setGeneric("f", function(x)standardGeneric("f"), where="DEST") setMethod("f", "character", function(x)toupper(x)) })) z