Hi, The acrobatics that as.data.frame.factor() is going thru in order to recognize a direct call don't play nice if as.data.frame() is an S4 generic: ??? df <- as.data.frame(factor(11:12)) ??? suppressPackageStartupMessages(library(BiocGenerics)) ??? isGeneric("as.data.frame") ??? # [1] TRUE ??? df <- as.data.frame(factor(11:12)) ??? # Warning message: ??? # In as.data.frame.factor(factor(11:12)) : ??? # ? Direct call of 'as.data.frame.factor()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead This spurious warning showed up on the recent Bioconductor daily build reports after we've updated the build machines to the latest R devel. It's causing some confusion and breaks at least one unit test. Thanks, H. > sessionInfo() R Under development (unstable) (2024-03-06 r86056) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 22.04.4 LTS Matrix products: default BLAS:?? /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 locale: ?[1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C ?[3] LC_TIME=en_GB????????????? LC_COLLATE=en_US.UTF-8 ?[5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8 ?[7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C ?[9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: America/New_York tzcode source: system (glibc) attached base packages: [1] stats???? graphics? grDevices utils???? datasets? methods base other attached packages: [1] BiocGenerics_0.49.1 loaded via a namespace (and not attached): [1] compiler_4.4.0 -- Herv? Pag?s Bioconductor Core Team hpages.on.github at gmail.com [[alternative HTML version deleted]]
? Tue, 12 Mar 2024 12:33:17 -0700 Herv? Pag?s <hpages.on.github at gmail.com> ?????:> The acrobatics that as.data.frame.factor() is going thru in order to > recognize a direct call don't play nice if as.data.frame() is an S4 > generic: > > ??? df <- as.data.frame(factor(11:12)) > > ??? suppressPackageStartupMessages(library(BiocGenerics)) > ??? isGeneric("as.data.frame") > ??? # [1] TRUE > > ??? df <- as.data.frame(factor(11:12)) > ??? # Warning message: > ??? # In as.data.frame.factor(factor(11:12)) : > ??? # ? Direct call of 'as.data.frame.factor()' is deprecated.How about something like the following: Index: src/library/base/R/zzz.R ==================================================================--- src/library/base/R/zzz.R (revision 86109) +++ src/library/base/R/zzz.R (working copy) @@ -681,7 +681,14 @@ bdy <- body(as.data.frame.vector) bdy <- bdy[c(1:2, seq_along(bdy)[-1L])] # taking [(1,2,2:n)] to insert at [2]: ## deprecation warning only when not called by method dispatch from as.data.frame(): - bdy[[2L]] <- quote(if((sys.nframe() <= 1L || !identical(sys.function(-1L), as.data.frame))) + bdy[[2L]] <- quote(if((sys.nframe() <= 1L || !( + identical(sys.function(-1L), as.data.frame) || ( + .isMethodsDispatchOn() && + methods::is(sys.function(-1L), 'derivedDefaultMethod') && + identical( + sys.function(-1L)@generic, + structure('as.data.frame', package = 'base') + ))))) .Deprecated( msg = gettextf( "Direct call of '%s()' is deprecated. Use '%s()' or '%s()' instead", The patch passes make check-devel, but I'm not sure how to safely put setGeneric('as.data.frame'); as.data.frame(factor(1:10)) in a regression test. -- Best regards, Ivan