This is not at all something new(*). As maintainer of the
Matrix package, I don't like this inconsistency of base R's diag().
We have had the following -- forever, almost surely inherited
from S and S+ :
diag(x) preserves the storage mode of x for 'complex' and
'double' precision, but convert
I would recommend against maintaining multiple global variables and would
instead take an object-oriented approach. Probably should define a
reference class representing a random number stream (think
java.util.Random). Then define a reference class representing a collection
of them, tracking which
Dear All,
What is the preferred way for Package A, to initialize a cluster, and load
Package B on all nodes?
I am writing a package that parallelizes some functions through the use of
a cluster if useRs are on a Windows machine (using parLapply and family).
I also make use of another package in
I am not an expert here, but if it's a package, couldn't (shouldn't?) you
include Package B in one of the Depends: or Imports: lines in the
DESCRIPTION file? That would ensure Package B is automatically made
accessible whenever Package A is loaded. For example, see the Writing R
Extensions manual:
Someone kindly pointed out that it is not clear from my email why Depends
will not work. A more complete example is:
PkgA:
f <- function(ncores) {
cl <- makeCluster(ncores)
clusterEvalQ(cl, {
require(PkgB)
})
[other code]
### this is the code I want to work and need to be able to
The safe, elegant way to do this is to use namespace scoping: it is
still not at all clear why 'other code' needs PkgB *on the search path*.
In other cases seen in CRAN submissions, 'other code' has been in PkgA's
namespace, and hence things in PkgB's exports have been visible as it
was import