Skip to content

Commit

Permalink
Merge branch 'master' into issue6846
Browse files Browse the repository at this point in the history
  • Loading branch information
venom1204 authored Mar 4, 2025
2 parents 58dff19 + 5c964b3 commit a0b7f2b
Show file tree
Hide file tree
Showing 34 changed files with 132 additions and 48 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Authors@R: c(
person("Tyson","Barrett", role=c("aut","cre"), email="t.barrett88@gmail.com", comment = c(ORCID="0000-0002-2137-1391")),
person("Matt","Dowle", role="aut", email="mattjdowle@gmail.com"),
person("Arun","Srinivasan", role="aut", email="asrini@pm.me"),
person("Jan","Gorecki", role="aut"),
person("Michael","Chirico", role="aut", comment = c(ORCID="0000-0003-0787-087X")),
person("Toby","Hocking", role="aut", comment = c(ORCID="0000-0002-3146-0865")),
person("Jan","Gorecki", role="aut", email="j.gorecki@wit.edu.pl"),
person("Michael","Chirico", role="aut", email="michaelchirico4@gmail.com", comment = c(ORCID="0000-0003-0787-087X")),
person("Toby","Hocking", role="aut", email="toby.hocking@r-project.org", comment = c(ORCID="0000-0002-3146-0865")),
person("Benjamin","Schwendinger",role="aut", comment = c(ORCID="0000-0003-3315-8114")),
person("Ivan", "Krylov", role="aut", email="ikrylov@disroot.org", comment = c(ORCID="0000-0002-0172-3812")),
person("Pasha","Stetsenko", role="ctb"),
Expand Down
4 changes: 4 additions & 0 deletions src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#if R_VERSION < R_Version(3, 4, 0)
# define SET_GROWABLE_BIT(x) // #3292
#endif
// TODO: remove the `R_SVN_VERSION` check when R 4.5.0 is released (circa Apr. 2025)
#if R_VERSION < R_Version(4, 5, 0) || R_SVN_REVISION < 86702
# define isDataFrame(x) isFrame(x) // #6180
#endif
#include <Rinternals.h>
#define SEXPPTR_RO(x) ((const SEXP *)DATAPTR_RO(x)) // to avoid overhead of looped STRING_ELT and VECTOR_ELT
#include <stdint.h> // for uint64_t rather than unsigned long long
Expand Down
2 changes: 1 addition & 1 deletion src/dogroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
for (int j=0; j<LENGTH(jval); ++j) {
thiscol = VECTOR_ELT(jval,j);
if (isNull(thiscol)) continue;
if (!isVector(thiscol) || isFrame(thiscol))
if (!isVector(thiscol) || isDataFrame(thiscol))
error(_("Entry %d for group %d in j=list(...) should be atomic vector or list. If you are trying something like j=list(.SD,newcol=mean(colA)) then use := by group instead (much quicker), or cbind or merge afterwards."), j+1, i+1);
if (isArray(thiscol)) {
SEXP dims = PROTECT(getAttrib(thiscol, R_DimSymbol));
Expand Down
4 changes: 2 additions & 2 deletions src/forder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ void putIndex(SEXP x, SEXP cols, SEXP o) {

// isTRUE(getOption("datatable.use.index"))
bool GetUseIndex(void) {
SEXP opt = GetOption(install("datatable.use.index"), R_NilValue);
SEXP opt = GetOption1(install("datatable.use.index"));
if (!IS_TRUE_OR_FALSE(opt))
error(_("'datatable.use.index' option must be TRUE or FALSE")); // # nocov
return LOGICAL(opt)[0];
Expand All @@ -1627,7 +1627,7 @@ bool GetAutoIndex(void) {
// for now temporarily 'forder.auto.index' not 'auto.index' to disabled it by default
// because it writes attr on .SD which is re-used by all groups leading to incorrect results
// DT[, .(uN=uniqueN(.SD)), by=A]
SEXP opt = GetOption(install("datatable.forder.auto.index"), R_NilValue);
SEXP opt = GetOption1(install("datatable.forder.auto.index"));
if (isNull(opt))
return false;
if (!IS_TRUE_OR_FALSE(opt))
Expand Down
12 changes: 8 additions & 4 deletions src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,10 @@ int freadMain(freadMainArgs _args) {
topQuoteRule = quoteRule;
firstJumpEnd = ch; // to know how many bytes jump 0 is, for nrow estimate later (a less-good estimate when fill=true since line lengths vary more)
if (verbose) {
DTPRINT((unsigned)sep<32 ? " sep=%#02x" : " sep='%c'", sep); // # notranslate
DTPRINT(_(" with %d fields using quote rule %d\n"), topNumFields, quoteRule);
DTPRINT((unsigned)sep<32
? _(" sep=%#02x with %d fields using quote rule %d\n")
: _(" sep='%c' with %d fields using quote rule %d\n"),
sep, topNumFields, quoteRule);
}
}
} else {
Expand Down Expand Up @@ -1780,8 +1782,10 @@ int freadMain(freadMainArgs _args) {
topSkip = thisRow-thisBlockLines;
if (topSkip<0) topSkip=0; // inelegant but will do for now to pass single row input such as test 890
if (verbose) {
DTPRINT((unsigned)sep<32 ? " sep=%#02x" : " sep='%c'", sep); // # notranslate
DTPRINT(_(" with %d lines of %d fields using quote rule %d\n"), topNumLines, topNumFields, topQuoteRule);
DTPRINT((unsigned)sep<32
? _(" sep=%#02x with %d lines of %d fields using quote rule %d\n")
: _(" sep='%c' with %d lines of %d fields using quote rule %d\n"),
sep, topNumLines, topNumFields, topQuoteRule);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/freadR.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ SEXP freadR(
args.logical01 = LOGICAL(logical01Arg)[0];
args.logicalYN = LOGICAL(logicalYNArg)[0];
{
SEXP tt = PROTECT(GetOption(sym_old_fread_datetime_character, R_NilValue));
SEXP tt = PROTECT(GetOption1(sym_old_fread_datetime_character));
args.oldNoDateTime = oldNoDateTime = isLogical(tt) && LENGTH(tt)==1 && LOGICAL(tt)[0]==TRUE;
UNPROTECT(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ inline double LLtoD(long long x) {

int GetVerbose(void) {
// don't call repetitively; save first in that case
SEXP opt = GetOption(sym_verbose, R_NilValue);
SEXP opt = GetOption1(sym_verbose);
if ((!isLogical(opt) && !isInteger(opt)) || LENGTH(opt)!=1 || INTEGER(opt)[0]==NA_INTEGER)
error(_("verbose option must be length 1 non-NA logical or integer"));
return INTEGER(opt)[0];
Expand Down
2 changes: 1 addition & 1 deletion src/rbindlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg, SEXP ignor
}
}
if (buff[0]) {
SEXP opt = GetOption(install("datatable.rbindlist.check"), R_NilValue);
SEXP opt = GetOption1(install("datatable.rbindlist.check"));
if (!isNull(opt) && !(isString(opt) && length(opt)==1)) {
warning(_("options()$datatable.rbindlist.check is set but is not a single string. See news item 5 in v1.12.2."));
opt = R_NilValue;
Expand Down
2 changes: 1 addition & 1 deletion src/subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ SEXP subsetDT(SEXP x, SEXP rows, SEXP cols) { // API change needs update NEWS.md
if (this<1 || this>LENGTH(x)) error(_("Item %d of cols is %d which is outside the range [1,ncol(x)=%d]"), i+1, this, LENGTH(x));
}

int overAlloc = checkOverAlloc(GetOption(install("datatable.alloccol"), R_NilValue));
int overAlloc = checkOverAlloc(GetOption1(install("datatable.alloccol")));
SEXP ans = PROTECT(allocVector(VECSXP, LENGTH(cols)+overAlloc)); nprotect++; // doing alloc.col directly here; eventually alloc.col can be deprecated.

// user-defined and superclass attributes get copied as from v1.12.0
Expand Down
23 changes: 23 additions & 0 deletions vignettes/_translation_links.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# build a link list of alternative languages (may be character(0))
# idea is to look like 'Other languages: en | fr | de'
.write.translation.links <- function(fmt) {
url = "https://rdatatable.gitlab.io/data.table/articles"
path = dirname(knitr::current_input(TRUE))
if (basename(path) == "vignettes") {
lang = "en"
} else {
lang = basename(path)
path = dirname(path)
}
translation = dir(path,
recursive = TRUE,
pattern = glob2rx(knitr::current_input(FALSE))
)
transl_lang = ifelse(dirname(translation) == ".", "en", dirname(translation))
block = if (!all(transl_lang == lang)) {
linked_transl = sprintf("[%s](%s)", transl_lang, file.path(url, sub("(?i)\\.Rmd$", ".html", translation)))
linked_transl[transl_lang == lang] = lang
sprintf(fmt, paste(linked_transl, collapse = " | "))
} else ""
knitr::asis_output(block)
}
6 changes: 3 additions & 3 deletions vignettes/datatable-benchmarking.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-benchmarking.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

This document is meant to guide on measuring performance of `data.table`. Single place to document best practices and traps to avoid.

Expand Down
6 changes: 3 additions & 3 deletions vignettes/datatable-faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-faq.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
library(data.table)
Expand Down
7 changes: 3 additions & 4 deletions vignettes/datatable-importing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-importing.html)
* [Russian](https://rdatatable.gitlab.io/data.table/articles/ru/datatable-importing.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

This document is focused on using `data.table` as a dependency in other R packages. If you are interested in using `data.table` C code from a non-R application, or in calling its C functions directly, jump to the [last section](#non-r-api) of this vignette.

Expand Down
7 changes: 3 additions & 4 deletions vignettes/datatable-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-intro.html)
* [Russian](https://rdatatable.gitlab.io/data.table/articles/ru/datatable-intro.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
4 changes: 4 additions & 0 deletions vignettes/datatable-joins.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ knitr::opts_chunk$set(
)
```

```{r, echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

In this vignette you will learn how to perform any join operation using resources available in the `data.table` syntax.

It assumes familiarity with the `data.table` syntax. If that is not the case, please read the following vignettes:
Expand Down
6 changes: 3 additions & 3 deletions vignettes/datatable-keys-fast-subset.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-keys-fast-subset.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
7 changes: 3 additions & 4 deletions vignettes/datatable-programming.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-programming.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r init, include = FALSE}
require(data.table)
Expand All @@ -24,7 +24,6 @@ knitr::opts_chunk$set(
)
```


## Introduction

`data.table`, from its very first releases, enabled the usage of `subset` and `with` (or `within`) functions by defining the `[.data.table` method. `subset` and `with` are base R functions that are useful for reducing repetition in code, enhancing readability, and reducing number the total characters the user has to type. This functionality is possible in R because of a quite unique feature called *lazy evaluation*. This feature allows a function to catch its arguments, before they are evaluated, and to evaluate them in a different scope than the one in which they were called. Let's recap usage of the `subset` function.
Expand Down
7 changes: 4 additions & 3 deletions vignettes/datatable-reference-semantics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-reference-semantics.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand All @@ -23,6 +23,7 @@ knitr::opts_chunk$set(
collapse = TRUE)
.old.th = setDTthreads(1)
```

This vignette discusses *data.table*'s reference semantics which allows to *add/update/delete* columns of a *data.table by reference*, and also combine them with `i` and `by`. It is aimed at those who are already familiar with *data.table* syntax, its general form, how to subset rows in `i`, select and compute on columns, and perform aggregations by group. If you're not familiar with these concepts, please read the [`vignette("datatable-intro", package="data.table")`](datatable-intro.html) vignette first.

***
Expand Down
7 changes: 3 additions & 4 deletions vignettes/datatable-reshape.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-reshape.html)
* [Russian](https://rdatatable.gitlab.io/data.table/articles/ru/datatable-reshape.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
6 changes: 3 additions & 3 deletions vignettes/datatable-sd-usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ vignette: >
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-sd-usage.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
6 changes: 3 additions & 3 deletions vignettes/datatable-secondary-indices-and-auto-indexing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-secondary-indices-and-auto-indexing.html)
```{r echo=FALSE, file='_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-benchmarking.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ h2 {
}
</style>

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

Ce document a pour but de guider la mesure de la performance de `data.table`. Il centralise la documentation des meilleures pratiques et des pièges à éviter.

# fread : effacer les caches
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ h2 {
#TOC { width: 100%; }
</style>

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
library(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-importing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ h2 {
}
</style>

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

Ce document se concentre sur l'utilisation de `data.table` comme dépendance dans d'autres packages R. Si vous souhaitez utiliser le code C de `data.table` à partir d'une application non-R, ou appeler directement ses fonctions C, passez à la [dernière section](#non-r-API) de cette vignette.

Importer `data.table` n'est pas différent qu'importer d'autres packages R. Cette vignette a pour but de répondre aux questions les plus courantes à ce sujet; les indications présentées ici peuvent être appliquées à d'autres packages R.
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-keys-fast-subset.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-programming.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r init, include = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-reference-semantics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-reshape.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-sd-usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../_translation_links.R'}
```
`r .write.translation.links("Translations of this document are available in: %s")`

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
Loading

0 comments on commit a0b7f2b

Please sign in to comment.