Otherwise, I think we're going to have to bite the
bullet and duplicate every function in our probability
lib to deal with defaults (this is, by the way, what
Boost does -- the core problem is that without the c++0x
extensions, you can't have a template parameter default
for a function.
Question 2
----------
How do I work with R when developing packages so
that I can uninstall and reinstall a package without
quitting R?
I managed to get Rcpp modules linking to the Stan
code, but I can't figure out how to get R to forget
about the last version and load the new one.
I can create my Rcpp module-based package using their
template as follows
SHELL
$ R CMD build mypkg
$ R CMD check mypkg
$ R CMD install mypkg
R
> require("mypkg")
> foo(2,3)
That all works fine, with foo(2,3) being
defined in my package. But then I change some code
and rebuild and reinstall the package
SHELL
$ R CMD remove mypkg
$ R CMD build mypkg
$ R CMD check mypkg
$ R CMD install mypkg
And then I go into R and do this:
R
> detach("package:mypkg")
> require("mypkg")
and I get the old version. If I then quit out of R
and start again, I get the new one without going back
to the shell, etc.
There's so much noise on the R lists about installing
packages that I can't find a single useful bit of advice.
- Bob
> How do I work with R when developing packages so
> that I can uninstall and reinstall a package without
> quitting R?
Does it work if you do
detach(package:mypkg, unload=TRUE)
If I don't unload, it brings back the previous version.
I can't find any help online -- lots of people have seen
these bugs, but no answers to what's going on I could find.
I'm hoping I'm just detaching/library-ing wrong somehow.
- Bob
> detach(package:mypkg, unload=TRUE)
> require('mypkg')
Loading required package: mypkg
*** caught segfault ***
address 0x90, cause 'memory not mapped'
Traceback:
1: .Call(symbol)
2: Module(m, pkg, mustStart = TRUE)
3: doTryCatch(return(expr), name, parentenv, handler)
4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
5: tryCatchList(expr, classes, parentenv, handlers)
6: tryCatch({ mod <- Module(m, pkg, mustStart = TRUE) if
(isTRUE(direct)) { populate(mod, ns) } else {
forceAssignInNamespace(m, mod, ns) }}, error = function(e) {
stop(sprintf("failed to load module %s from package %s\n%s", m,
pkg, conditionMessage(e)))})
7: loadRcppModules()
8: fun(...)
9: doTryCatch(return(expr), name, parentenv, handler)
10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
11: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch(fun(...), error = identity)
13: runHook(".onLoad", package, env, package.lib, package)
14: loadNamespace(package, c(which.lib.loc, lib.loc), keep.source =
keep.source)
15: doTryCatch(return(expr), name, parentenv, handler)
16: tryCatchOne(expr, names, parentenv, handlers[[1L]])
17: tryCatchList(expr, classes, parentenv, handlers)
18: tryCatch(expr, error = function(e) { call <- conditionCall(e)
if (!is.null(call)) { if (identical(call[[1L]],
quote(doTryCatch))) call <- sys.call(-4L) dcall <-
deparse(call)[1L] prefix <- paste("Error in", dcall, ": ")
LONG <- 75L msg <- conditionMessage(e) sm <-
strsplit(msg, "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") +
nchar(sm[1L], type = "w") if (is.na(w)) w <- 14L +
nchar(dcall, type = "b") + nchar(sm[1L], type = "b")
if (w > LONG) prefix <- paste(prefix, "\n ", sep = "")
} else prefix <- "Error : " msg <- paste(prefix,
conditionMessage(e), "\n", sep = "")
.Internal(seterrmessage(msg[1L])) if (!silent &&
identical(getOption("show.error.messages"), TRUE)) {
cat(msg, file = stderr()) .Internal(printDeferredWarnings()) }
invisible(structure(msg, class = "try-error"))})
19: try({ ns <- loadNamespace(package, c(which.lib.loc, lib.loc),
keep.source = keep.source) dataPath <- file.path(which.lib.loc,
package, "data") env <- attachNamespace(ns, pos = pos, dataPath =
dataPath, deps)})
20: library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, warn.conflicts = warn.conflicts, quietly =
quietly, keep.source = keep.source)
21: doTryCatch(return(expr), name, parentenv, handler)
22: tryCatchOne(expr, names, parentenv, handlers[[1L]])
23: tryCatchList(expr, classes, parentenv, handlers)
24: tryCatch(library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, warn.conflicts = warn.conflicts, quietly =
quietly, keep.source = keep.source), error = function(e) e)
25: require("mypkg")
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
That was fun. The result was a seg-fault:
Question 1
----------
Does anyone know how to control the version of
g++ used by R? The default version shipped with the
Mac isn't up to our template defaults yet, but it's
easy to install a new compiler that is. I'd like to
tell R to use that one.
Question 2
----------
How do I work with R when developing packages so
that I can uninstall and reinstall a package without
quitting R?
https://github.com/hadley/devtools
HTH,
/au
--
Austin Frank
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
Question 1
----------
Does anyone know how to control the version of
g++ used by R? The default version shipped with the
Mac isn't up to our template defaults yet, but it's
easy to install a new compiler that is. I'd like to
tell R to use that one.
Otherwise, I think we're going to have to bite the
bullet and duplicate every function in our probability
lib to deal with defaults (this is, by the way, what
Boost does -- the core problem is that without the c++0x
extensions, you can't have a template parameter default
for a function.