Skip to content

Commit 6ad0524

Browse files
Progress deprecation of in.place argument (#6652)
1 parent ebbf128 commit 6ad0524

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
@@ -149,6 +149,8 @@ rowwiseDT(
149149
150150
11. Deprecation of `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release.
151151
152+
12. 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.
153+
152154
# data.table [v1.16.4](https://github.com/Rdatatable/data.table/milestone/36) 4 December 2024
153155
154156
## 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
@@ -17785,7 +17785,7 @@ if (base::getRversion() >= "3.4.0") {
1778517785
}
1778617786
test(2214.06, droplevels(DT)[["a"]], droplevels(DT[1:5,a]))
1778717787
test(2214.07, droplevels(DT, 1)[["a"]], x[1:5])
17788-
test(2214.08, droplevels(DT, in.place=TRUE), DT, warning="droplevels() with in.place=TRUE is deprecated.")
17788+
test(2214.08, droplevels(DT, in.place=TRUE), error="droplevels() with in.place=TRUE is deprecated.")
1778917789
# support ordered factors in fdroplevels
1779017790
o = factor(letters[1:10], ordered=TRUE)
1779117791
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)