[R-pkg-devel] Whack-a-mole base::assign(".ptime", proc.time(), pos = "CheckExEnv")

2019-04-29 Thread Mark Hogue
(The subject title is in reference to the arcade game where fake mole heads
pop up and the contestant is challenged to smash them down as more and more
keep popping up.)

I made some changes to a package and when I run the R CMD check, I get one
error with this lead-in notification:

Running examples in 'radsafer-Ex.R' failed
  The error most likely occurred in:
*base::assign(".ptime", proc.time(), pos = "CheckExEnv")*

When I do something with the affected function, I get a similar error on
another function.

Could it have something to do with my having added argument checks on these
functions? Could someone advise where to go to understand this error
better? And is it normal to get only one error at a time like this?

Thanks,

Mark

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] check warning in examples

2019-04-29 Thread Duncan Murdoch

On 29/04/2019 6:12 p.m., Berry Boessenkool wrote:


Hi,

my package has a warning in check (locally + all rhub::check_for_cran 
platforms):

* checking for unstated dependencies in examples ... WARNING
Warning: parse error in file 'berryFunctions-Ex.R':
'match' requires vector arguments

When I run the -Ex.R file locally (Windows 10, R3.5.2), things work fine, 
however.
parse("*-Ex.R") works fine.
devtools::run_examples() works fine as well.
https://github.com/brry/berryFunctions

Does anybody have an idea how to locate the cause for such a warning?
Does it mean something that this turns up in check unstated deps while checking 
examples itself has no problems?



It looks like a bug in the QC code, triggered by this line in one of 
your examples for ?dataStr:


  data(list=x$Call, package=x$Package, envir=env)

In the R-devel source file src/library/tools/R/QC.R, in function 
.check_packages_used_helper(), there's a nested function called 
find_bad_exprs().  It parses lots of calls, and in particular, in 
handling calls to data(), it has this code:



if(Call %in%  "data" && length(e) >= 3L) {
mc <- match.call(utils::data, e)
if(!is.null(pkg <- mc$package) && pkg %notin% 
depends_suggests)

bad_data <<- c(bad_data, pkg)
}

Here e is the quoted expression from above, and Call is "data".  This 
sets pkg to the quoted expression x$package, and the test "pkg %notin% 
depends_suggests" dies with the error message you saw.


I think the fix for this is to check that pkg works out to be a string, 
not an expression, e.g.


 if(!is.null(pkg <- mc$package) && is.character(pkg) && pkg %notin% 
depends_suggests)


I'm not sure what would be the best thing for you to do.  You could fool 
the test by using obscure code like this


  do.call("data", list(list = x$Call, package=x$Package, envir=env))

or maybe you could just ignore the warning, pointing out that it is a 
bug in the QC code.


Duncan Murdoch

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] parallel computing slower than sequential computing

2019-04-29 Thread Wang, Zhu
Hello,

I have a package where parallel computing is slower than sequential computing 
with cross-validation. For instance, please see the following reproducible 
example with 10 cores and the relevant lines in the corresponding R function. 
The R package is also attached. I thought parallel computing should improve the 
speed. However, it is not obvious to me where it went wrong.

Many thanks in advance.

Zhu Wang

library("mpath")
library("pscl")
data("bioChemists", package = "pscl")
>system.time(cv.zipath(art ~ . | ., data = bioChemists, family = "negbin", 
>nlambda=100, parallel=FALSE))
user  system elapsed
  77.430   0.031  79.547
> system.time(cv.zipath(art ~ . | ., data = bioChemists, family = "negbin", 
> nlambda=100, parallel=TRUE, n.cores=10))
user  system elapsed
  95.694   0.517 106.072
R> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

The relevant lines in cv.zipath regarding parallel argument are below:

if(parallel){
 registerDoParallel(cores=n.cores)
 i <- 1  ###needed to pass R CMD check with parallel code below
 residmat <- foreach(i=seq(K), .combine=cbind, .packages='mpath') %dopar% {
 omit <- all.folds[[i]]
 fitcv <- do.call("zipath", list(formula, data[-omit,], weights[-omit], 
 lambda.count=lambda.count, lambda.zero=lambda.zero, nlambda=nlambda, ...))
 logLik(fitcv, newdata=data[omit,, drop=FALSE], Y[omit],
 weights=weights[omit])
 }
 stopImplicitCluster()
 }
 else{
  residmat <- matrix(NA, nlambda, K)
  for(i in seq(K)) {
if(trace)
  cat("\n CV Fold", i, "\n\n")
omit <- all.folds[[i]]
fitcv <- do.call("zipath", list(formula, data[-omit,], weights[-omit],  
 lambda.count=lambda.count, lambda.zero=lambda.zero, nlambda=nlambda, ...))
residmat[, i] <- logLik(fitcv, newdata=data[omit,, drop=FALSE], 
 Y[omit], weights=weights[omit])
  }
 }


mpath_0.3-13.tar.gz
Description: mpath_0.3-13.tar.gz
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] data in R package

2019-04-29 Thread Duncan Murdoch

On 29/04/2019 5:03 a.m., Raffaele Argiento wrote:

Dear all


we are developing a R package and we would like to include as an
example  published data that we have taken from a paper. Is this
allowed ? Where can I find the policy about distributing data through
the R Package


There are two answers to this.  If you are intending to distribute your 
package on CRAN, then the appropriate document is


https://cran.r-project.org/web/packages/policies.html

Relevant parts of it would likely be the rules about size and copyright 
status, but there may be other parts too:  read it over.


If you are not intending to distribute on CRAN, then you are pretty free 
to do whatever you want, subject to the laws of your country.  R has no 
standing to control what you do with your own creation.


Duncan Murdoch

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] data in R package

2019-04-29 Thread Ralf Stubner
On 29.04.19 11:03, Raffaele Argiento wrote:
> we are developing a R package and we would like to include as an
> example  published data that we have taken from a paper. Is this
> allowed ? Where can I find the policy about distributing data through
> the R Package

From the CRAN policies
:

  Packages should be of the minimum necessary size. Reasonable
  compression should be used for data (not just .rda files) and PDF
  documentation: CRAN will if necessary pass the latter through qpdf.

  As a general rule, neither data nor documentation should exceed 5MB
  (which covers several books). A CRAN package is not an appropriate way
  to distribute course notes, and authors will be asked to trim their
  documentation to a maximum of 5MB.

  Where a large amount of data is required (even after compression),
  consideration should be given to a separate data-only package which
  can be updated only rarely (since older versions of packages are
  archived in perpetuity).

Besides these technical questions, one also has to consider legal
questions: Under which license may one distribute the data?

Greetings
Ralf

-- 
Ralf Stubner
Senior Software Engineer / Trainer

daqana GmbH
Dortustraße 48
14467 Potsdam

T: +49 331 23 61 93 11
F: +49 331 23 61 93 90
M: +49 162 20 91 196
Mail: ralf.stub...@daqana.com

Sitz: Potsdam
Register: AG Potsdam HRB 27966
Ust.-IdNr.: DE300072622
Geschäftsführer: Dr.-Ing. Stefan Knirsch, Prof. Dr. Dr. Karl-Kuno Kunze



signature.asc
Description: OpenPGP digital signature
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] data in R package

2019-04-29 Thread Raffaele Argiento
Dear all


we are developing a R package and we would like to include as an
example  published data that we have taken from a paper. Is this
allowed ? Where can I find the policy about distributing data through
the R Package

Thanks

-- 
Dr. Raffaele Argiento

University of Torino and Collegio Carlo Alberto

www.raffaeleargiento.it

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel