Skip to content

Commit b81b0a8

Browse files
authored
Merge branch 'master' into rm-key-set
2 parents 336dd4f + 5ecf963 commit b81b0a8

File tree

13 files changed

+73
-77
lines changed

13 files changed

+73
-77
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ 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. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
140+
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.
141+
142+
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.
143+
144+
9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
141145
142146
# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)
143147

R/data.table.R

Lines changed: 2 additions & 4 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
@@ -2077,8 +2077,6 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
20772077
if (!is.null(rownames)) {
20782078
if (!is.null(rownames.value)) stopf("rownames and rownames.value cannot both be used at the same time")
20792079
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")
20822080
if (length(rownames)!=nrow(x))
20832081
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))
20842082
rownames.value = rownames

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) {

R/fwrite.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
33
sep2=c("","|",""), eol=if (.Platform$OS.type=="windows") "\r\n" else "\n",
44
na="", dec=".", row.names=FALSE, col.names=TRUE,
55
qmethod=c("double","escape"),
6-
logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
6+
logical01=getOption("datatable.logical01", FALSE),
77
logicalAsInt=logical01,
88
scipen=getOption('scipen', 0L),
99
dateTimeAs = c("ISO","squash","epoch","write.csv"),

man/fread.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ key=NULL, index=NULL,
2222
showProgress=getOption("datatable.showProgress", interactive()),
2323
data.table=getOption("datatable.fread.datatable", TRUE),
2424
nThread=getDTthreads(verbose),
25-
logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
25+
logical01=getOption("datatable.logical01", FALSE),
2626
logicalYN=getOption("datatable.logicalYN", FALSE),
2727
keepLeadingZeros = getOption("datatable.keepLeadingZeros", FALSE),
2828
yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC"

man/fwrite.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fwrite(x, file = "", append = FALSE, quote = "auto",
1111
eol = if (.Platform$OS.type=="windows") "\r\n" else "\n",
1212
na = "", dec = ".", row.names = FALSE, col.names = TRUE,
1313
qmethod = c("double","escape"),
14-
logical01 = getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
14+
logical01 = getOption("datatable.logical01", FALSE),
1515
logicalAsInt = logical01, # deprecated
1616
scipen = getOption('scipen', 0L),
1717
dateTimeAs = c("ISO","squash","epoch","write.csv"),

man/setkey.Rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ setindex(DT, B)
142142
indices(DT) # get indices single vector
143143
indices(DT, vectors = TRUE) # get indices list
144144

145+
# Setting multiple indices at once
146+
DT = data.table(A = 5:1, B = letters[5:1], C = 10:6)
147+
setindexv(DT, list(c("A", "B"), c("B", "C")))
148+
print(DT, show.indices=TRUE)
149+
145150
# Use the dot .(subset_value) syntax with integer keys:
146151
DT = data.table(id = 2:1)
147152
setkey(DT, id)

src/chmatch.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ static SEXP chmatchMain(SEXP x, SEXP table, int nomatch, bool chin, bool chmatch
3535
return ans;
3636
}
3737
// Since non-ASCII strings may be marked with different encodings, it only make sense to compare
38-
// the bytes under a same encoding (UTF-8) #3844 #3850
38+
// the bytes under a same encoding (UTF-8) #3844 #3850.
39+
// Not 'const' because we might SET_TRUELENGTH() below.
3940
SEXP *xd;
4041
if (isSymbol(x)) {
4142
xd = &sym;
4243
} else {
43-
xd = STRING_PTR_RO(PROTECT(coerceUtf8IfNeeded(x))); nprotect++;
44+
xd = (SEXP *)STRING_PTR_RO(PROTECT(coerceUtf8IfNeeded(x))); nprotect++;
4445
}
4546
const SEXP *td = STRING_PTR_RO(PROTECT(coerceUtf8IfNeeded(table))); nprotect++;
4647
if (xlen==1) {

src/coalesce.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
5353
first = PROTECT(copyAsPlain(first)); nprotect++;
5454
if (verbose) Rprintf(_("coalesce copied first item (inplace=FALSE)\n"));
5555
}
56-
void **valP = (void **)R_alloc(nval, sizeof(void *));
56+
const void **valP = (const void **)R_alloc(nval, sizeof(void *));
5757
switch(TYPEOF(first)) {
5858
case LGLSXP:
5959
case INTSXP: {
@@ -66,7 +66,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
6666
finalVal = tt;
6767
break; // stop early on the first singleton that is not NA; minimizes deepest loop body below
6868
}
69-
valP[k++] = INTEGER(item);
69+
valP[k++] = INTEGER_RO(item);
7070
}
7171
const bool final=(finalVal!=NA_INTEGER);
7272
#pragma omp parallel for num_threads(getDTthreads(nrow, true))
@@ -89,7 +89,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
8989
finalVal = tt;
9090
break;
9191
}
92-
valP[k++] = REAL(item);
92+
valP[k++] = REAL_RO(item);
9393
}
9494
const bool final = (finalVal!=NA_INTEGER64);
9595
#pragma omp parallel for num_threads(getDTthreads(nrow, true))
@@ -110,7 +110,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
110110
finalVal = tt;
111111
break;
112112
}
113-
valP[k++] = REAL(item);
113+
valP[k++] = REAL_RO(item);
114114
}
115115
const bool final = !ISNAN(finalVal);
116116
#pragma omp parallel for num_threads(getDTthreads(nrow, true))
@@ -133,7 +133,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
133133
finalVal = tt;
134134
break;
135135
}
136-
valP[k++] = COMPLEX(item);
136+
valP[k++] = COMPLEX_RO(item);
137137
}
138138
const bool final = !ISNAN(finalVal.r) && !ISNAN(finalVal.i);
139139
#pragma omp parallel for num_threads(getDTthreads(nrow, true))

0 commit comments

Comments
 (0)