[R-pkg-devel] CRAN submission with "possibly unsafe calls" or alternative approach?

Rainer M Krug R@|ner @end|ng |rom krug@@de
Fri Dec 6 10:05:20 CET 2019


Hi

In my package `dmdScheme` I define three variables. Depending on a state in the package (a selected metadata schemes) these are set as followed from within the package:

```
  unlockBinding("dmdScheme_example", as.environment("package:dmdScheme"))
  assign("dmdScheme_example", scheme_example, "package:dmdScheme")
  lockBinding("dmdScheme_example", as.environment("package:dmdScheme"))


  scheme_raw <- as_dmdScheme_raw(scheme_example)
  unlockBinding("dmdScheme_raw", as.environment("package:dmdScheme"))
  assign("dmdScheme_raw", scheme_raw, "package:dmdScheme")
  lockBinding("dmdScheme_raw", as.environment("package:dmdScheme"))


  scheme <- as_dmdScheme(scheme_raw, keepData = FALSE, checkVersion = FALSE)
  unlockBinding("dmdScheme", as.environment("package:dmdScheme"))
  assign("dmdScheme", scheme, "package:dmdScheme")
  lockBinding("dmdScheme", as.environment("package:dmdScheme”))
```

( See https://github.com/Exp-Micro-Ecol-Hub/dmdScheme/blob/b97e7b5ef116476e065aeec1da1050eecbd6adf7/R/scheme_use.R#L37-L49 )

My reasoning is that I want to lock these variables, as they are essential to the functioning of the package.

But I get, probably not surprising, the following NOTE:


```
* checking R code for possible problems ... NOTE
Found the following possibly unsafe calls:
File ‘dmdScheme/R/scheme_use.R’:
  unlockBinding("dmdScheme_example", as.environment("package:dmdScheme"))
  unlockBinding("dmdScheme_raw", as.environment("package:dmdScheme"))
  unlockBinding("dmdScheme", as.environment("package:dmdScheme"))
```

For the submission to CRAN, Can I disregard this note and explain it during the submission?

My second question concerns the values itself. I set the variables to NULL in the /data folder in the package, but even after they are set as above, the valuee in `dmdScheme::dmdScheme` is still NULL:

```
> names(dmdScheme)
[1] "Experiment"       "Genus"            "Treatments"       "Measurement"
[5] "DataExtraction"   "DataFileMetaData"
> names(dmdScheme::dmdScheme)
NULL
>
```

Is there a way, that I can change the value of dmdScheme::… variables during runtime?

Thanks,

Rainer


--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug using uzh.ch
		Rainer using krugs.de
Skype:     RMkrug

PGP: 0x0F52F982



More information about the R-package-devel mailing list