Skip to content

Commit 1f4a30e

Browse files
Progress deprecation of in.place argument
1 parent 436bd6c commit 1f4a30e

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ rowwiseDT(
137137

138138
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).
139139

140+
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.
141+
140142
# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)
141143

142144
## BUG FIXES

R/fdroplevels.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ fdroplevels = function(x, exclude = if (anyNA(levels(x))) NULL else NA, ...) {
88
return(ans)
99
}
1010

11-
droplevels.data.table = function(x, except=NULL, exclude, in.place=FALSE, ...){
12-
stopifnot(is.logical(in.place))
13-
if (isTRUE(in.place)) warningf("droplevels() with in.place=TRUE is deprecated. Use setdroplevels() instead.")
14-
if (!in.place) x = copy(x)
11+
droplevels.data.table = function(x, except=NULL, exclude, in.place=NULL, ...){
12+
if (!is.null(in.place)) stopf("droplevels() with in.place=TRUE is deprecated. Use setdroplevels() instead.")
13+
x = copy(x)
1514
if (missing(exclude)) exclude = NULL
1615
setdroplevels(x, except, exclude)[]
1716
}

inst/tests/tests.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17794,7 +17794,7 @@ if (base::getRversion() >= "3.4.0") {
1779417794
}
1779517795
test(2214.06, droplevels(DT)[["a"]], droplevels(DT[1:5,a]))
1779617796
test(2214.07, droplevels(DT, 1)[["a"]], x[1:5])
17797-
test(2214.08, droplevels(DT, in.place=TRUE), DT, warning="droplevels() with in.place=TRUE is deprecated.")
17797+
test(2214.08, droplevels(DT, in.place=TRUE), error="droplevels() with in.place=TRUE is deprecated.")
1779817798
# support ordered factors in fdroplevels
1779917799
o = factor(letters[1:10], ordered=TRUE)
1780017800
test(2214.09, fdroplevels(o[1:5]), droplevels(o[1:5]))

man/fdroplevels.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
fdroplevels(x, exclude = if (anyNA(levels(x))) NULL else NA, \dots)
1313
setdroplevels(x, except = NULL, exclude = NULL)
1414

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

0 commit comments

Comments
 (0)