diff --git a/NEWS.md b/NEWS.md index 885eb56c5..fa384dc10 100644 --- a/NEWS.md +++ b/NEWS.md @@ -137,6 +137,8 @@ rowwiseDT( 6. `measurev()` was implemented and documented in v1.15.0, for use within `melt()`, and it is now exported (dependent packages can now use without a NOTE from CRAN check). +7. The `dcast()` and `melt()` generics no longer attempt to redirect to {reshape2} methods when passed non-`data.table`s. If you're still using {reshape2}, you must use namespace-qualification: `reshape2::dcast()`, `reshape2::melt()`. We have been warning about the deprecation since v1.12.4 (2019). Please note that {reshape2} is retired. + # data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024) ## BUG FIXES diff --git a/R/fcast.R b/R/fcast.R index ac7b5f218..c0dbfd4e3 100644 --- a/R/fcast.R +++ b/R/fcast.R @@ -12,17 +12,10 @@ dcast <- function( data, formula, fun.aggregate = NULL, ..., margins = NULL, subset = NULL, fill = NULL, value.var = guess(data) ) { - if (is.data.table(data)) UseMethod("dcast", data) - # nocov start - else { - data_name = deparse(substitute(data)) - ns = tryCatch(getNamespace("reshape2"), error=function(e) - stopf("The %1$s generic in data.table has been passed a %2$s, but data.table::%1$s currently only has a method for data.tables. Please confirm your input is a data.table, with setDT(%3$s) or as.data.table(%3$s). If you intend to use a method from reshape2, try installing that package first, but do note that reshape2 is superseded and is no longer actively developed.", "dcast", class1(data), data_name)) - warningf("The %1$s generic in data.table has been passed a %2$s and will attempt to redirect to the relevant reshape2 method; please note that reshape2 is superseded and is no longer actively developed, and this redirection is now deprecated. Please do this redirection yourself like reshape2::%1$s(%3$s). In the next version, this warning will become an error.", "dcast", class1(data), data_name) - ns$dcast(data, formula, fun.aggregate = fun.aggregate, ..., margins = margins, - subset = subset, fill = fill, value.var = value.var) - } - # nocov end + # TODO(>=1.19.0): Remove this, just let dispatch to 'default' method fail. + if (!is.data.table(data)) + stopf("The %1$s generic in data.table has been passed a %2$s, but data.table::%1$s currently only has a method for data.tables. Please confirm your input is a data.table, with setDT(%3$s) or as.data.table(%3$s). If you intend to use a method from reshape2, try installing that package first, but do note that reshape2 is superseded and is no longer actively developed.", "dcast", class1(data), deparse(substitute(data))) # nocov + UseMethod("dcast", data) } check_formula = function(formula, varnames, valnames, value.var.in.LHSdots, value.var.in.RHSdots) { diff --git a/R/fmelt.R b/R/fmelt.R index c0cc47e9c..38ef06435 100644 --- a/R/fmelt.R +++ b/R/fmelt.R @@ -1,22 +1,15 @@ # reshape2 dependency was originally abandoned because (1) we wanted to be in control # of the R version dependency and (2) reshape2::dcast is not generic. -# reshape2 package is deprecated since December 2017, so we'll deprecate our +# reshape2 package is deprecated since December 2017, so we've deprecated our # redirection as well melt = function(data, ..., na.rm = FALSE, value.name = "value") { UseMethod("melt", data) } +# TODO(>=1.19.0): Remove this, just let dispatch to 'default' method fail. melt.default = function(data, ..., na.rm = FALSE, value.name = "value") { - # if no registered method exists for data, attempts to redirect data to reshape2::melt; - # CRAN package edarf and others fail without the redirection - # nocov start - data_name = deparse(substitute(data)) - ns = tryCatch(getNamespace("reshape2"), error=function(e) - stopf("The %1$s generic in data.table has been passed a %2$s, but data.table::%1$s currently only has a method for data.tables. Please confirm your input is a data.table, with setDT(%3$s) or as.data.table(%3$s). If you intend to use a method from reshape2, try installing that package first, but do note that reshape2 is superseded and is no longer actively developed.", "melt", class1(data), data_name)) - warningf("The %1$s generic in data.table has been passed a %2$s and will attempt to redirect to the relevant reshape2 method; please note that reshape2 is superseded and is no longer actively developed, and this redirection is now deprecated. To continue using melt methods from reshape2 while both packages are attached, e.g. melt.list, you can prepend the namespace, i.e. reshape2::%1$s(%3$s). In the next version, this warning will become an error.", "melt", class1(data), data_name) - ns$melt(data, ..., na.rm=na.rm, value.name=value.name) - # nocov end + stopf("The %1$s generic in data.table has been passed a %2$s and will attempt to redirect to the relevant reshape2 method; please note that reshape2 is superseded and is no longer actively developed, and this redirection is now deprecated. To continue using melt methods from reshape2 while both packages are attached, e.g. melt.list, you can prepend the namespace, i.e. reshape2::%1$s(%3$s). In the next version, this warning will become an error.", "melt", class1(data), deparse(substitute(data))) # nocov } patterns = function(..., cols=character(0L), ignore.case=FALSE, perl=FALSE, fixed=FALSE, useBytes=FALSE) {