From j@g@nmn2 @end|ng |rom gm@||@com  Thu Jul  6 17:32:00 2023
From: j@g@nmn2 @end|ng |rom gm@||@com (Mikael Jagan)
Date: Thu, 6 Jul 2023 11:32:00 -0400
Subject: [Rd] logic tweak needed for as.data.frame.<class> deprecation
 warning
Message-ID: <730ed025-b919-6d76-4263-6462d37f40e8@gmail.com>

Continuing the thread started on R-package-devel, here:
https://stat.ethz.ch/pipermail/r-package-devel/2023q3/009307.html

The logic of the now soft-deprecated as.data.frame.<class>,

 > body(as.data.frame.integer)[[2L]]
if ((sys.nframe() <= 1L || sys.call(-1L)[[1L]] != quote(as.data.frame)) &&
     nzchar(Sys.getenv("_R_CHECK_AS_DATA_FRAME_EXPLICIT_METHOD_"))) 
.Deprecated(msg = gettextf("Direct call of '%s()' is deprecated.  Use '%s()' or 
'%s()' instead",
     "as.data.frame.integer", "as.data.frame.vector", "as.data.frame"))

may need adjustment to avoid false positives such as this one:

 > Sys.setenv("_R_CHECK_AS_DATA_FRAME_EXPLICIT_METHOD_" = TRUE)
 > f <- as.data.frame
 > f(0L)
   0L
1  0
Warning message:
Direct call of 'as.data.frame.integer()' is deprecated.  Use 
'as.data.frame.vector()' or 'as.data.frame()' instead

i.e., the condition sys.call(-1L)[[1L]] != quote(as.data.frame) is not precise
enough ... would !identical(sys.function(-1L), as.data.frame) work instead?

Mikael



[Rd] logic tweak needed for as.data.frame.<class> deprecation warning
Mikael Jagan