Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Gábor Csárdi
On Wed, Dec 16, 2020 at 8:39 PM Henrik Bengtsson wrote: > > BTW, 'backports' provides a backport for tools::R_user_dir() also for > R (< 4.0.0), so an alternative solution in this case is: > > Imports: backports > > and > > importFrom(backports, R_user_dir) > > The 'backports' package takes the

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Henrik Bengtsson
BTW, 'backports' provides a backport for tools::R_user_dir() also for R (< 4.0.0), so an alternative solution in this case is: Imports: backports and importFrom(backports, R_user_dir) The 'backports' package takes the same approach as I did in my previous message. Henrik On Wed, Dec 16, 2020

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Henrik Bengtsson
Colin, you can do: Imports: tools NAMESPACE: if (getRversion() >= 4) importFrom(tools,R_user_dir) R/000.namespace.R: ## Create a dummy R_user_dir() for R (< 4.0.0) ## to please R CMD check if (getRversion() < 4) { R_user_dir <- function(...) NULL } and then use: if (getRversion() < 4) {

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Jeff Newmiller
For "obvious" reasons? I don't see this kind of avoidance as "obviously" correct at all. You have a dependency... it should be declared. There are various ways to proceed, with Imports or Depends or Suggests or pulling the code into your package... but trying to subvert the dependency

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Sebastian Meyer
Am 16.12.20 um 18:00 schrieb Neal Fultz: > IIRC some packages use get() instead of double-colon to suppress the NOTE. I'd discourage from using get() because you could (accidentally) access even unexported objects from another namespace. There is getExportedValue(ns, name) to avoid that.

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Neal Fultz
IIRC some packages use get() instead of double-colon to suppress the NOTE. I would probably ignore it myself. On Wed, Dec 16, 2020 at 8:29 AM Colin Gillespie wrote: > > Hi, > > I'm planning on using the tools::R_user_dir function in a package. But > for obvious reasons, I don't want to set the

Re: [R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread brodie gaslam via R-package-devel
I don't know if this will work in your case (or even if it is a good or bad thing to do), but backports conditionally exports the function in question, e.g.: https://github.com/r-lib/backports/blob/master/R/lengths.R So in that example their implementation of a function not available in R <

[R-pkg-devel] Accessing features in R4.0.

2020-12-16 Thread Colin Gillespie
Hi, I'm planning on using the tools::R_user_dir function in a package. But for obvious reasons, I don't want to set the dependency on R 4. My code is basically if (as.numeric(R.version$major) < 4) # do something else tools::R_user_dir("oysteR", which = "cache") When checking on win-builder