Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress deprecation of in.place argument to droplevels.data.table #6652

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. Deprecation of `droplevels(in.place=TRUE)` (warning since v1.16.0) has been upgraded from warning to error. The argument will be removed in the next release.

# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)

## BUG FIXES
Expand Down
7 changes: 3 additions & 4 deletions R/fdroplevels.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ fdroplevels = function(x, exclude = if (anyNA(levels(x))) NULL else NA, ...) {
return(ans)
}

droplevels.data.table = function(x, except=NULL, exclude, in.place=FALSE, ...){
stopifnot(is.logical(in.place))
if (isTRUE(in.place)) warningf("droplevels() with in.place=TRUE is deprecated. Use setdroplevels() instead.")
if (!in.place) x = copy(x)
droplevels.data.table = function(x, except=NULL, exclude, in.place=NULL, ...){
ben-schwen marked this conversation as resolved.
Show resolved Hide resolved
if (!is.null(in.place)) stopf("droplevels() with in.place=TRUE is deprecated. Use setdroplevels() instead.")
x = copy(x)
if (missing(exclude)) exclude = NULL
setdroplevels(x, except, exclude)[]
}
Expand Down
2 changes: 1 addition & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -17794,7 +17794,7 @@ if (base::getRversion() >= "3.4.0") {
}
test(2214.06, droplevels(DT)[["a"]], droplevels(DT[1:5,a]))
test(2214.07, droplevels(DT, 1)[["a"]], x[1:5])
test(2214.08, droplevels(DT, in.place=TRUE), DT, warning="droplevels() with in.place=TRUE is deprecated.")
test(2214.08, droplevels(DT, in.place=TRUE), error="droplevels() with in.place=TRUE is deprecated.")
# support ordered factors in fdroplevels
o = factor(letters[1:10], ordered=TRUE)
test(2214.09, fdroplevels(o[1:5]), droplevels(o[1:5]))
Expand Down
4 changes: 2 additions & 2 deletions man/fdroplevels.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
fdroplevels(x, exclude = if (anyNA(levels(x))) NULL else NA, \dots)
setdroplevels(x, except = NULL, exclude = NULL)

\method{droplevels}{data.table}(x, except = NULL, exclude, in.place = FALSE, \dots)
\method{droplevels}{data.table}(x, except = NULL, exclude, in.place = NULL, \dots)
}
\arguments{
\item{x}{ \code{factor} or \code{data.table} where unused levels should be dropped. }
\item{exclude}{ A \code{character} vector of factor levels which are dropped no matter of presented or not. }
\item{except}{ An \code{integer} vector of indices of data.table columns which are not modified by dropping levels. }
\item{in.place}{ logical (default is \code{FALSE}). If \code{TRUE} levels of factors of \code{data.table} are modified in-place. }
\item{in.place}{ Deprecated. Use \code{setdroplevels} for in-place modification. }
\item{\dots}{ further arguments passed to methods }
}

Expand Down
Loading