[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 12:30:19 CET 2019


Thanks for the clarification - I was not aware of that. I will put the variables in an environment and call them via a function before submission to CRAN..

Thanks,

Rainer


> On 6 Dec 2019, at 12:03, peter dalgaard <pdalgd using gmail.com> wrote:
> 
> I think you may want to rethink the mechanism. 
> 
> Locked bindings are generally there to allow the compiler to make assumptions about the type, etc., of objects (or rather: not make assumptions because it will know what the type is). Unlocking invalidates this and may trigger recompilation or introduce errors. (There are people who know the details much better than I do).
> 
> I seem to recall that people have come up with ways to set up an environment which can contain mutable objects of this sort.
> 
> -pd
> 
>> On 6 Dec 2019, at 10:05 , Rainer M Krug <Rainer using krugs.de> wrote:
>> 
>> 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
>> 
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
> 

--
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




	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list