Skip to content

Commit 950c28d

Browse files
Merge branch 'master' into deprect-droplevels
2 parents 1f4a30e + ebbf128 commit 950c28d

File tree

26 files changed

+234
-170
lines changed

26 files changed

+234
-170
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM docker.io/rhub/r-minimal:devel
2+
3+
RUN apk update \
4+
&& apk add --no-cache \
5+
gcc git musl-dev openmp pkgconf tzdata zlib-dev \
6+
&& echo 'options("repos"="https://cloud.r-project.org")' >> /usr/local/lib/R/etc/Rprofile.site
7+
8+
ENV TZDIR=/usr/share/zoneinfo
9+
10+
COPY DESCRIPTION .
11+
12+
RUN Rscript -e ' \
13+
read.dcf("DESCRIPTION", c("Imports", "Suggests")) |> \
14+
tools:::.split_dependencies() |> \
15+
names() |> \
16+
setdiff(tools:::.get_standard_package_names()$base) |> \
17+
install.packages(repos="https://cloud.r-project.org") \
18+
'
19+
20+
# setup cc()
21+
WORKDIR /root
22+
COPY .devcontainer/.Rprofile .
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"build": { "dockerfile": "Dockerfile", "context": "../.." },
3+
"customizations": { "vscode": {
4+
"extensions": [
5+
"REditorSupport.r",
6+
"ms-vscode.cpptools-extension-pack"
7+
]
8+
}}
9+
}

.github/ISSUE_TEMPLATE/issue_template.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ about: Report a bug or describe a new requested feature
55

66
Click preview tab ^^^ above!
77

8-
By continuing to file this new issue / feature request, I confirm I have :
8+
By continuing to file this new issue / feature request, I confirm I have:
99
1. searched the [live NEWS file](https://github.com/Rdatatable/data.table/blob/master/NEWS.md) to see if it has been fixed in dev already. If so, I tried the [latest dev version](https://github.com/Rdatatable/data.table/wiki/Installation#windows).
1010
2. looked at the titles of all the issues in the [current milestones](https://github.com/Rdatatable/data.table/milestones) and am aware of those. (Adding new information to existing issues is very helpful and appreciated.)
1111
3. [searched all issues](https://github.com/Rdatatable/data.table/issues) (i.e. not in a milestone yet) for similar issues to mine and will include links to them explaining why mine is different.
1212
4. searched on [Stack Overflow's data.table tag](http://stackoverflow.com/questions/tagged/data.table) and there is nothing similar there.
1313
5. read the [Support](https://github.com/Rdatatable/data.table/wiki/Support) and [Contributing](https://github.com/Rdatatable/data.table/blob/master/.github/CONTRIBUTING.md) guides.
14-
6. please don't tag your issue with text in the title; project members will add the appropriate tags later.
14+
15+
Some general advice on the title and description fields for your PR
16+
17+
- Please don't tag your issue with text in the title like '[Joins]'; project members will add the appropriate tags later.
18+
- Don't write text like 'Closes #xxx' in the PR title either; GitHub does not recognize this text, whereas GitHub auto-links issues in the description, [see docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword).
19+
- Title and Description fields should try and be self-contained as much as possible. The title answers "what is this change" and the description provides necessary details/thought processes/things tried but abandoned. Imagine visiting your PR in 5 years' time and trying to glean what it's all about quickly and without needing to open 10 new tabs.
1520

1621
#### Thanks! Please remove the text above and include the two items below.
1722

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ importFrom(methods, "S3Part<-", slotNames)
55
exportClasses(data.table, IDate, ITime)
66
##
77

8-
export(data.table, tables, setkey, setkeyv, key, "key<-", haskey, CJ, SJ, copy)
8+
export(data.table, tables, setkey, setkeyv, key, haskey, CJ, SJ, copy)
99
export(rowwiseDT)
1010
export(setindex, setindexv, indices)
1111
export(as.data.table,is.data.table,test.data.table)

NEWS.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ rowwiseDT(
9595
# [1] "V1" "b" "c"
9696
```
9797

98-
4. Queries like `DT[, min(x):max(x)]` now work as expected, i.e. the same as `DT[, seq(min(x), max(x))]` or `with(DT, min(x):max(x))`, [#2069](https://github.com/Rdatatable/data.table/issues/2069). Shorthand like `DT[, a:b]` meaning "select from columns `a` through `b`" still works. Thanks to @franknarf1 for reporting, @jangorecki for the fix, and @MichaelChirico for a follow-up ensuring back-compatibility.
98+
4. Queries like `DT[, min(x):max(x)]` now work as expected, i.e. the same as `DT[, seq(min(x), max(x))]` or `with(DT, min(x):max(x))`, [#2069](https://github.com/Rdatatable/data.table/issues/2069). Shorthand like `DT[, a:b]` meaning "select from columns `a` through `b`" still works. Thanks to @franknarf1 for reporting, @jangorecki for the fix, and @MichaelChirico for follow-ups ensuring back-compatibility.
9999

100100
5. `fread()` performance improves when specifying `Date` among `colClasses`, [#6105](https://github.com/Rdatatable/data.table/issues/6105). One implication of the change is that the column will be an `IDate` (which also inherits from `Date`), which may affect code strongly relying on the column class to be `Date` exactly; computations with `IDate` and `Date` columns should otherwise be the same. If you strongly prefer the `Date` class, run `as.Date()` explicitly following `fread()`. Thanks @scipima for the report and @MichaelChirico for the fix.
101101

@@ -111,17 +111,19 @@ rowwiseDT(
111111
112112
11. `tables()` now returns the correct size for data.tables over 2GiB, [#6607](https://github.com/Rdatatable/data.table/issues/6607). Thanks to @vlulla for the report and the PR.
113113
114-
12. Joins on multiple columns, such as `x[y, on=c("x1==y1", "x2==y1")]`, could fail during implicit type coercions if `x1` and `x2` had different but still compatible types, [#6602](https://github.com/Rdatatable/data.table/issues/6602). This was particularly unexpected when columns `x1`, `x2`, and `y1` were all of the same class, e.g. `Date`, but differed in their underlying storage types. Thanks to Benjamin Schwendinger for the report and the fix.
114+
12. `rbindlist(l, use.names=TRUE)` can now handle different encodings for the column names in different entries of `l`, [#5452](https://github.com/Rdatatable/data.table/issues/5452). Thanks to @MEO265 for the report, and Benjamin Schwendinger for the fix.
115115
116-
13. `rbindlist(l, use.names=TRUE)` can now handle different encodings for the column names in different entries of `l`, [#5452](https://github.com/Rdatatable/data.table/issues/5452). Thanks to @MEO265 for the report, and Benjamin Schwendinger for the fix.
116+
13. Added a `data.frame` method for `format_list_item()` to fix error printing data.tables with columns containing 1-column data.frames, [#6592](https://github.com/Rdatatable/data.table/issues/6592). Thanks to @r2evans for the bug report and fix.
117117
118-
14. Added a `data.frame` method for `format_list_item()` to fix error printing data.tables with columns containing 1-column data.frames, [#6592](https://github.com/Rdatatable/data.table/issues/6592). Thanks to @r2evans for the bug report and fix.
119-
120-
15. Auto-printing gets some substantial improvements
118+
14. Auto-printing gets some substantial improvements
121119
- Suppression in `knitr` documents is now done by implementing a method for `knit_print` instead of looking up the call stack, [#6589](https://github.com/Rdatatable/data.table/pull/6589). The old way was fragile and wound up broken by some implementation changes in {knitr}. Thanks to @jangorecki for the report [#6509](https://github.com/Rdatatable/data.table/issues/6509) and @aitap for the fix.
122120
- `print()` methods for S3 subclasses of data.table (e.g. an object of class `c("my.table", "data.table", "data.frame")`) no longer print where plain data.tables wouldn't, e.g. `myDT[, y := 2]`, [#3029](https://github.com/Rdatatable/data.table/issues/3029). The improved detection of auto-printing scenarios has the added benefit of _allowing_ print in highly explicit statements like `print(DT[, y := 2])`, obviating our recommendation since v1.9.6 to append `[]` to signal "please print me".
123121

124-
16. Joins of `integer64` and `double` columns succeed when the `double` column has lossless `integer64` representation, [#4167](https://github.com/Rdatatable/data.table/issues/4167) and [#6625](https://github.com/Rdatatable/data.table/issues/6625). Previously, this only worked when the double column had lossless _32-bit_ integer representation. Thanks @MichaelChirico for the reports and fix.
122+
15. Joins of `integer64` and `double` columns succeed when the `double` column has lossless `integer64` representation, [#4167](https://github.com/Rdatatable/data.table/issues/4167) and [#6625](https://github.com/Rdatatable/data.table/issues/6625). Previously, this only worked when the double column had lossless _32-bit_ integer representation. Thanks @MichaelChirico for the reports and fix.
123+
124+
16. `DT[order(...)]` better matches `base::order()` behavior by (1) recognizing the `method=` argument (and erroring since this is not supported) and (2) accepting a vector of `TRUE`/`FALSE` in `decreasing=` as an alternative to using `-a` to convey "sort `a` decreasing", [#4456](https://github.com/Rdatatable/data.table/issues/4456). Thanks @jangorecki for the FR and @MichaelChirico for the PR.
125+
126+
17. Assignment with `:=` to an S4 slot of an under-allocated data.table now works, [#6704](https://github.com/Rdatatable/data.table/issues/6704). Thanks @MichaelChirico for the report and fix.
125127

126128
## NOTES
127129

@@ -137,7 +139,23 @@ rowwiseDT(
137139

138140
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).
139141

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.
142+
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.
143+
144+
8. `showProgress` in `[` is disabled for "trivial" grouping (`.NGRP==1L`), [#6668](https://github.com/Rdatatable/data.table/issues/6668). Thanks @MichaelChirico for the request and @joshhwuu for the PR.
145+
146+
9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
147+
148+
10. Deprecation of `logicalAsInt` argument to `fwrite()` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release.
149+
150+
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.
151+
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+
154+
# data.table [v1.16.4](https://github.com/Rdatatable/data.table/milestone/36) 4 December 2024
155+
156+
## BUG FIXES
157+
158+
1. Joins on multiple columns, such as `x[y, on=c("x1==y1", "x2==y1")]`, could fail during implicit type coercions if `x1` and `x2` had different but still compatible types, [#6602](https://github.com/Rdatatable/data.table/issues/6602). This was particularly unexpected when columns `x1`, `x2`, and `y1` were all of the same class, e.g. `Date`, but differed in their underlying storage types. Thanks to Benjamin Schwendinger for the report and the fix.
141159
142160
# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)
143161

R/data.table.R

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ replace_dot_alias = function(e) {
459459
if (!len_common_names) stopf("Attempting to do natural join but no common columns in provided tables")
460460
if (verbose) {
461461
which_cols_msg = if (len_common_names == length(x)) {
462-
catf("Joining but 'x' has no key, natural join using all 'x' columns")
462+
catf("Joining but 'x' has no key, natural join using all 'x' columns\n")
463463
} else {
464-
catf("Joining but 'x' has no key, natural join using: %s", brackify(common_names))
464+
catf("Joining but 'x' has no key, natural join using: %s\n", brackify(common_names))
465465
}
466466
}
467467
on = common_names
@@ -1221,7 +1221,7 @@ replace_dot_alias = function(e) {
12211221
setalloccol(x, n, verbose=verbose) # always assigns to calling scope; i.e. this scope
12221222
if (is.name(name)) {
12231223
assign(as.character(name),x,parent.frame(),inherits=TRUE)
1224-
} else if (name %iscall% c('$', '[[') && is.name(name[[2L]])) {
1224+
} else if (.is_simple_extraction(name)) { # TODO(#6702): use a helper here as the code is very similar to setDT().
12251225
k = eval(name[[2L]], parent.frame(), parent.frame())
12261226
if (is.list(k)) {
12271227
origj = j = if (name[[1L]] == "$") as.character(name[[3L]]) else eval(name[[3L]], parent.frame(), parent.frame())
@@ -1233,6 +1233,8 @@ replace_dot_alias = function(e) {
12331233
.Call(Csetlistelt,k,as.integer(j), x)
12341234
} else if (is.environment(k) && exists(as.character(name[[3L]]), k)) {
12351235
assign(as.character(name[[3L]]), x, k, inherits=FALSE)
1236+
} else if (isS4(k)) {
1237+
.Call(CsetS4elt, k, as.character(name[[3L]]), x)
12361238
}
12371239
} # TO DO: else if env$<- or list$<-
12381240
}
@@ -2077,8 +2079,6 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
20772079
if (!is.null(rownames)) {
20782080
if (!is.null(rownames.value)) stopf("rownames and rownames.value cannot both be used at the same time")
20792081
if (length(rownames)>1L) {
2080-
# TODO in future as warned in NEWS for 1.11.6:
2081-
# warningf("length(rownames)>1 is deprecated. Please use rownames.value= instead")
20822082
if (length(rownames)!=nrow(x))
20832083
stopf("length(rownames)==%d but nrow(DT)==%d. The rownames argument specifies a single column name or number. Consider rownames.value= instead.", length(rownames), nrow(x))
20842084
rownames.value = rownames
@@ -2969,7 +2969,7 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
29692969
if (is.name(name)) {
29702970
name = as.character(name)
29712971
assign(name, x, parent.frame(), inherits=TRUE)
2972-
} else if (name %iscall% c('$', '[[') && is.name(name[[2L]])) {
2972+
} else if (.is_simple_extraction(name)) {
29732973
# common case is call from 'lapply()'
29742974
k = eval(name[[2L]], parent.frame(), parent.frame())
29752975
if (is.list(k)) {
@@ -2981,9 +2981,11 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
29812981
stopf("Item '%s' not found in names of input list", origj)
29822982
}
29832983
}
2984-
.Call(Csetlistelt,k,as.integer(j), x)
2984+
.Call(Csetlistelt, k, as.integer(j), x)
29852985
} else if (is.environment(k) && exists(as.character(name[[3L]]), k)) {
29862986
assign(as.character(name[[3L]]), x, k, inherits=FALSE)
2987+
} else if (isS4(k)) {
2988+
.Call(CsetS4elt, k, as.character(name[[3L]]), x)
29872989
}
29882990
}
29892991
.Call(CexpandAltRep, x) # issue#2866 and PR#2882
@@ -3047,9 +3049,12 @@ rleidv = function(x, cols=seq_along(x), prefix=NULL) {
30473049
if (root != ":") return(FALSE)
30483050
if (!length(vars)) return(TRUE) # e.g. 1:10
30493051
if (!all(vars %chin% names(x))) return(TRUE) # e.g. 1:ncol(x)
3050-
is.name(e[[1L]]) && is.name(e[[2L]]) # e.g. V1:V2, but not min(V1):max(V2) or 1:max(V2)
3052+
!is.call(e[[2L]]) && !is.call(e[[3L]]) # e.g. V1:V2, but not min(V1):max(V2) or 1:max(V2)
30513053
}
30523054

3055+
# for assignments like x[[1]][, a := 2] or setDT(x@DT)
3056+
.is_simple_extraction = function(e) e %iscall% c('$', '@', '[[') && is.name(e[[2L]])
3057+
30533058
# GForce functions
30543059
# to add a new function to GForce (from the R side -- the easy part!):
30553060
# (1) add it to gfuns

R/fcast.R

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@ dcast <- function(
1212
data, formula, fun.aggregate = NULL, ..., margins = NULL,
1313
subset = NULL, fill = NULL, value.var = guess(data)
1414
) {
15-
if (is.data.table(data)) UseMethod("dcast", data)
16-
# nocov start
17-
else {
18-
data_name = deparse(substitute(data))
19-
ns = tryCatch(getNamespace("reshape2"), error=function(e)
20-
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))
21-
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)
22-
ns$dcast(data, formula, fun.aggregate = fun.aggregate, ..., margins = margins,
23-
subset = subset, fill = fill, value.var = value.var)
24-
}
25-
# nocov end
15+
# TODO(>=1.19.0): Remove this, just let dispatch to 'default' method fail.
16+
if (!is.data.table(data))
17+
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
18+
UseMethod("dcast", data)
2619
}
2720

2821
check_formula = function(formula, varnames, valnames, value.var.in.LHSdots, value.var.in.RHSdots) {

R/fmelt.R

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
# reshape2 dependency was originally abandoned because (1) we wanted to be in control
22
# of the R version dependency and (2) reshape2::dcast is not generic.
3-
# reshape2 package is deprecated since December 2017, so we'll deprecate our
3+
# reshape2 package is deprecated since December 2017, so we've deprecated our
44
# redirection as well
55

66
melt = function(data, ..., na.rm = FALSE, value.name = "value") {
77
UseMethod("melt", data)
88
}
99

10+
# TODO(>=1.19.0): Remove this, just let dispatch to 'default' method fail.
1011
melt.default = function(data, ..., na.rm = FALSE, value.name = "value") {
11-
# if no registered method exists for data, attempts to redirect data to reshape2::melt;
12-
# CRAN package edarf and others fail without the redirection
13-
# nocov start
14-
data_name = deparse(substitute(data))
15-
ns = tryCatch(getNamespace("reshape2"), error=function(e)
16-
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))
17-
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)
18-
ns$melt(data, ..., na.rm=na.rm, value.name=value.name)
19-
# nocov end
12+
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
2013
}
2114

2215
patterns = function(..., cols=character(0L), ignore.case=FALSE, perl=FALSE, fixed=FALSE, useBytes=FALSE) {

0 commit comments

Comments
 (0)