Skip to content

Commit 6c570ce

Browse files
authored
Merge branch 'master' into issue____2611
2 parents 7827275 + 08ea530 commit 6c570ce

File tree

9 files changed

+44
-18
lines changed

9 files changed

+44
-18
lines changed

.github/workflows/pkgup.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
Rscript -e 'stopifnot(file.copy("DESCRIPTION", file.path(tdir<-tempdir(), "PACKAGES"))); db<-available.packages(paste0("file://", tdir)); deps<-setdiff(tools::package_dependencies(read.dcf("DESCRIPTION", fields="Package")[[1L]], db, which="most")[[1L]], installed.packages(priority="high")[,"Package"]); if (length(deps)) { ap<-available.packages()[,"Version"]; ap<-ap[names(ap) %in% deps]; if (!all(deps%in%names(ap))) stop("dependencies are not avaiable in repository: ",paste(setdiff(deps, names(ap)), collapse=", ")); ip<-installed.packages()[,"Version"]; ip<-ip[names(ip) %in% deps]; pkgs<-ap[deps]>ip[deps]; install.packages(names(pkgs[pkgs|is.na(pkgs)]), INSTALL_opts="--html") }'
4040
- name: build
4141
run: |
42-
sed -i "0,/^Version: [0-9.]\+$/s//&-$(TZ=UTC git log -1 --format=%ct)/" ./DESCRIPTION
4342
echo "Revision:" $GITHUB_SHA >> ./DESCRIPTION
4443
R CMD build .
4544
- name: check

.gitlab-ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ build:
7777
- rm -r bus
7878
script:
7979
- sed -i '/^[[:space:]]*$/d' ./DESCRIPTION ## make last line end abruptly; i.e. without a final \n
80-
- |
81-
sed -i "0,/^Version: [0-9.]\+$/s//&-$(TZ=UTC git log -1 --format=%ct)/" ./DESCRIPTION
8280
- echo "Revision:" $CI_COMMIT_SHA >> ./DESCRIPTION
8381
- R CMD build .
8482
- mkdir -p bus/$CI_JOB_NAME/
@@ -184,7 +182,7 @@ test-lin-dev-gcc-strict-cran:
184182
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
185183
- (! grep "warning:" data.table.Rcheck/00install.out)
186184
- >-
187-
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 3 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (size of tarball, non-API calls, V8 package) but ", shQuote(l)) else q("no")'
185+
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 2 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (non-API calls, V8 package) but ", shQuote(l)) else q("no")'
188186
189187
## R-devel on Linux clang
190188
# R compiled with clang, flags removed: -flto=auto -fopenmp
@@ -207,7 +205,7 @@ test-lin-dev-clang-cran:
207205
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
208206
- (! grep "warning:" data.table.Rcheck/00install.out)
209207
- >-
210-
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 3 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (size of tarball, non-API calls, V8 package) but ", shQuote(l)) else q("no")'
208+
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 2 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (non-API calls, V8 package) but ", shQuote(l)) else q("no")'
211209
212210
# stated dependency on R
213211
test-lin-ancient-cran:

R/onLoad.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# check when installed package is loaded but skip when developing the package with cc()
1515
dllV = if (is.loaded("CdllVersion",PACKAGE="data_table")) .Call(CdllVersion) else "before 1.12.0"
1616
RV = as.character(packageVersion("data.table"))
17-
if (sum(.dots <- charToRaw(RV) == charToRaw(".")) > 2L) {
18-
## trim dev version suffix 1.17.99-1234567890, note that base:::package_version turns `-` into `.` #7339
19-
RV = substring(RV, 1L, which(.dots)[3L]-1L)
20-
}
2117
if (dllV != RV) {
2218
dll = if (.Platform$OS.type=="windows") "dll" else "so"
2319
# https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<!-- badges: start -->
55
[![CRAN status](https://badges.cranchecks.info/flavor/release/data.table.svg)](https://cran.r-project.org/web/checks/check_results_data.table.html)
6-
[![R-CMD-check](https://github.com/Rdatatable/data.table/workflows/R-CMD-check/badge.svg)](https://github.com/Rdatatable/data.table/actions)
6+
[![R-CMD-check](https://github.com/Rdatatable/data.table/actions/workflows/R-CMD-check.yaml/badge.svg?branch=master)](https://github.com/Rdatatable/data.table/actions)
77
[![Codecov test coverage](https://codecov.io/github/Rdatatable/data.table/coverage.svg?branch=master)](https://app.codecov.io/github/Rdatatable/data.table?branch=master)
88
[![GitLab CI build status](https://gitlab.com/Rdatatable/data.table/badges/master/pipeline.svg)](https://rdatatable.gitlab.io/data.table/web/checks/check_results_data.table.html)
99
[![downloads](https://cranlogs.r-pkg.org/badges/data.table)](https://www.rdocumentation.org/trends)

man/data.table.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ DT[, list(MySum=sum(v),
422422
MyMax=max(v)),
423423
by=.(x, y\%\%2)] # by 2 expressions
424424

425+
# programmatic query with env=
426+
DT[, .(funvar = fun(var)), by=grp_var,
427+
env = list(fun="sum", var="a", funvar="sum_a_by_x", grp_var="x")]
428+
425429
DT[, .(a = .(a), b = .(b)), by=x] # list columns
426430
DT[, .(seq = min(a):max(b)), by=x] # j is not limited to just aggregations
427431
DT[, sum(v), by=x][V1<20] # compound query

man/mergelist.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ l = list(
113113
lapply(l[-1L], `[`, j = if (.N>1L) .SD, by = "id1") ## duplicated rows
114114
try(mergelist(l, on="id1"))
115115

116+
\donttest{
116117
## 'star schema' and 'snowflake schema' examples (realistic data sizes)
117118

118119
### populate fact: US population by state and date
@@ -199,4 +200,5 @@ ans = mergelist(list(
199200
setmergelist(rev(geog), how="right")
200201
))
201202
}
203+
}
202204
\keyword{ data }

src/fifelse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ SEXP fcaseR(SEXP rho, SEXP args) {
217217
int nprotect=0, l;
218218
int64_t n_ans=0, n_this_arg=0, n_undecided=0;
219219
SEXP ans=R_NilValue, tracker=R_NilValue, whens=R_NilValue, thens=R_NilValue;
220-
SEXP ans_class, ans_levels;
220+
SEXP ans_class, ans_levels = R_NilValue;
221221
PROTECT_INDEX Iwhens, Ithens;
222222
PROTECT_WITH_INDEX(whens, &Iwhens); nprotect++;
223223
PROTECT_WITH_INDEX(thens, &Ithens); nprotect++;
224224
SEXPTYPE ans_type=NILSXP;
225225
// naout means if the output is scalar logic na
226226
bool imask = true, naout = false, idefault = false;
227-
bool ans_is_factor;
227+
bool ans_is_factor = false;
228228
int *restrict p = NULL;
229229
const int n = narg/2;
230230
for (int i=0; i<n; ++i) {

src/fread.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ int freadMain(freadMainArgs _args)
16891689
if (ch >= eof) STOP(_("Input is either empty, fully whitespace, or skip has been set after the last non-whitespace."));
16901690
if (verbose) {
16911691
if (lineStart > ch) DTPRINT(_(" Moved forward to first non-blank line (%d)\n"), row1line);
1692-
DTPRINT(_(" Positioned on line %d starting: <<%s>>\n"), row1line, strlim(lineStart, (char[500]) {}, 30));
1692+
DTPRINT(_(" Positioned on line %d starting: <<%s>>\n"), row1line, strlim(lineStart, (char[500]) {0}, 30));
16931693
}
16941694
ch = pos = lineStart;
16951695
}
@@ -1880,7 +1880,7 @@ int freadMain(freadMainArgs _args)
18801880
if (!fill && tt != ncol) INTERNAL_STOP("first line has field count %d but expecting %d", tt, ncol); // # nocov
18811881
if (verbose) {
18821882
DTPRINT(_(" Detected %d columns on line %d. This line is either column names or first data row. Line starts as: <<%s>>\n"),
1883-
tt, row1line, strlim(pos, (char[500]) {}, 30));
1883+
tt, row1line, strlim(pos, (char[500]) {0}, 30));
18841884
DTPRINT(_(" Quote rule picked = %d\n"), quoteRule);
18851885
DTPRINT(_(" fill=%s and the most number of columns found is %d\n"), fill ? "true" : "false", ncol);
18861886
}
@@ -2809,23 +2809,23 @@ int freadMain(freadMainArgs _args)
28092809
while (ch < eof && *ch != '\n' && *ch != '\r') ch++;
28102810
while (ch < eof && isspace(*ch)) ch++;
28112811
if (ch == eof) {
2812-
DTWARN(_("Discarded single-line footer: <<%s>>"), strlim(skippedFooter, (char[500]) {}, 500));
2812+
DTWARN(_("Discarded single-line footer: <<%s>>"), strlim(skippedFooter, (char[500]) {0}, 500));
28132813
}
28142814
else {
28152815
ch = headPos;
28162816
int tt = countfields(&ch);
28172817
if (fill > 0) {
28182818
DTWARN(_("Stopped early on line %"PRId64". Expected %d fields but found %d. Consider fill=%d or even more based on your knowledge of the input file. Use fill=Inf for reading the whole file for detecting the number of fields. First discarded non-empty line: <<%s>>"),
2819-
DTi + row1line, ncol, tt, tt, strlim(skippedFooter, (char[500]) {}, 500));
2819+
DTi + row1line, ncol, tt, tt, strlim(skippedFooter, (char[500]) {0}, 500));
28202820
} else {
28212821
DTWARN(_("Stopped early on line %"PRId64". Expected %d fields but found %d. Consider fill=TRUE. First discarded non-empty line: <<%s>>"),
2822-
DTi + row1line, ncol, tt, strlim(skippedFooter, (char[500]) {}, 500));
2822+
DTi + row1line, ncol, tt, strlim(skippedFooter, (char[500]) {0}, 500));
28232823
}
28242824
}
28252825
}
28262826
}
28272827
if (quoteRuleBumpedCh != NULL && quoteRuleBumpedCh < headPos) {
2828-
DTWARN(_("Found and resolved improper quoting out-of-sample. First healed line %"PRId64": <<%s>>. If the fields are not quoted (e.g. field separator does not appear within any field), try quote=\"\" to avoid this warning."), quoteRuleBumpedLine, strlim(quoteRuleBumpedCh, (char[500]) {}, 500));
2828+
DTWARN(_("Found and resolved improper quoting out-of-sample. First healed line %"PRId64": <<%s>>. If the fields are not quoted (e.g. field separator does not appear within any field), try quote=\"\" to avoid this warning."), quoteRuleBumpedLine, strlim(quoteRuleBumpedCh, (char[500]) {0}, 500));
28292829
}
28302830

28312831
if (verbose) {

vignettes/datatable-programming.Rmd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,33 @@ DT[filter_col %in% filter_val,
204204
)]
205205
```
206206

207+
### Substitute functions
208+
209+
A tiny clarification may be useful on how we can substitute a function name in an expression.
210+
Note that providing `outer="sqrt"` (string) vs. `outer=sqrt` (symbol) is very different:
211+
```{r substitute_fun1, result='hide'}
212+
DT[, outer(Sepal.Length), env = list(outer="sqrt"), verbose=TRUE]
213+
#Argument 'j' after substitute: sqrt(Sepal.Length)
214+
## DT[, sqrt(Sepal.Length)]
215+
216+
DT[, outer(Sepal.Length), env = list(outer=sqrt), verbose=TRUE]
217+
#Argument 'j' after substitute: .Primitive("sqrt")(Sepal.Length)
218+
## DT[, .Primitive("sqrt")(Sepal.Length)]
219+
```
220+
And while `.Primitive("sqrt")(Sepal.Length)` still works, it is almost never the desired form.
221+
222+
Even more importantly, if the symbol form is meant to be used, then it can, and should, be used directly in the expression, as there is no need for substitution.
223+
```{r substitute_fun2, result='hide'}
224+
DT[, sqrt(Sepal.Length)]
225+
```
226+
227+
If function name to be substituted needs to be namespace-qualified then namespace and function name can be substituted as any other symbol in the expression:
228+
```{r substitute_fun3, result='hide', eval=FALSE}
229+
DT[, ns::fun(Sepal.Length), env = list(ns="base", fun="sqrt"), verbose=TRUE]
230+
#Argument 'j' after substitute: base::sqrt(Sepal.Length)
231+
## DT[, base::sqrt(Sepal.Length)]
232+
```
233+
207234
### Substitute variables and character values
208235

209236
In the above example, we have seen a convenient feature of `substitute2`: automatic conversion from strings into names/symbols. An obvious question arises: what if we actually want to substitute a parameter with a *character* value, so as to have base R `substitute` behaviour. We provide a mechanism to escape automatic conversion by wrapping the elements into base R `I()` call. The `I` function marks an object as *AsIs*, preventing its arguments from character-to-symbol automatic conversion. (Read the `?AsIs` documentation for more details.) If base R behaviour is desired for the whole `env` argument, then it's best to wrap the whole argument in `I()`. Alternatively, each list element can be wrapped in `I()` individually. Let's explore both cases below.

0 commit comments

Comments
 (0)