Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fedc6ef
add first steps
ben-schwen Oct 19, 2024
b1f1adb
add litedown R CMD check occasional
ben-schwen Oct 19, 2024
2fc3ddc
remove knitr::opts_chunk
ben-schwen Oct 19, 2024
ac1fb44
set comment char
ben-schwen Oct 19, 2024
905586d
add error option
ben-schwen Oct 19, 2024
1c14712
update comment char
ben-schwen Oct 20, 2024
aa7bdad
adjust print
ben-schwen Nov 2, 2024
071078c
remove space
ben-schwen Nov 2, 2024
1f347bd
fix namespace
ben-schwen Nov 2, 2024
e1d0c6f
Update vignettes/datatable-benchmarking.Rmd
ben-schwen Mar 8, 2025
4e7809f
use yihuis suggestions
ben-schwen Mar 8, 2025
c653cf6
Merge branch 'master' into litedown
ben-schwen Mar 8, 2025
4bacd15
upd translation script and r -> {r} code blocks
rikivillalba Mar 9, 2025
a1819e1
Merge branch 'master' into litedown
ben-schwen Mar 24, 2025
5ed155d
move knitr tests
ben-schwen Mar 24, 2025
e1329dd
Merge branch 'master' into litedown
ben-schwen Apr 21, 2025
e4b7912
Enhances: knitr
aitap Apr 22, 2025
1e191d5
Register xfun::record_print method for data.table
aitap Apr 22, 2025
0cfa02a
Merge branch 'master' into litedown
ben-schwen Jul 7, 2025
58b767d
add nocov
ben-schwen Jul 7, 2025
9759281
add nocov for knitr_print
ben-schwen Jul 7, 2025
9f35906
nocov range
MichaelChirico Jul 8, 2025
9a49b1d
Add missing periods.
aitap Jul 8, 2025
010c238
Fix footnote
aitap Jul 8, 2025
d01e83c
Fix remaining `r ...` expressions
aitap Jul 8, 2025
d9300ad
Merge branch 'master' into litedown
ben-schwen Jul 28, 2025
e32a5db
update joins vignette
ben-schwen Jul 28, 2025
a6afc0a
set/unset threads
ben-schwen Jul 28, 2025
bae1e3c
sys.date
ben-schwen Jul 28, 2025
ea7eec4
add xfun to enhances
ben-schwen Jul 28, 2025
cc9bf5d
add litedown mock
ben-schwen Jul 30, 2025
de27098
Merge branch 'master' into litedown
ChristianWia Sep 12, 2025
3d62dc3
translation links knitr compatible
rikivillalba Oct 27, 2025
55227bc
code block for automatic translation links
rikivillalba Oct 27, 2025
be197d9
change `{r} Sys.date()` by !r Sys.date() in YAML header
rikivillalba Oct 28, 2025
1285908
translation script tweaks
rikivillalba Oct 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dev/CRAN_Release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Rdevel-strict-[gcc|clang] CMD check data.table_1.16.99.tar.gz
Rdevel-strict-[gcc|clang]
isTRUE(.Machine$sizeof.longdouble==0) # check noLD is being tested
options(repos = "http://cloud.r-project.org")
install.packages(c("bit64", "bit", "R.utils", "xts", "zoo", "yaml", "knitr", "markdown"),
install.packages(c("bit64", "bit", "R.utils", "xts", "zoo", "yaml", "litedown"),
Ncpus=4)
# Issue #5491 showed that CRAN is running UBSAN on .Rd examples which found an error so we now run full R CMD check
q("no")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-occasional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
TEST_DATA_TABLE_WITH_OTHER_PACKAGES=as.character(run_other)
)

do_vignettes = requireNamespace("knitr", quietly=TRUE)
do_vignettes = requireNamespace("litedown", quietly=TRUE)

build_args = NULL
check_args = c("--no-manual", "--as-cran")
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Version: 1.17.99
Title: Extension of `data.frame`
Depends: R (>= 3.4.0)
Imports: methods
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils, xts, zoo (>= 1.8-1), yaml, knitr, markdown
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils, xts, zoo (>= 1.8-1), yaml, litedown
Enhances: knitr, xfun
Description: Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns, friendly and fast character-separated-value read/write. Offers a natural and flexible syntax, for faster development.
License: MPL-2.0 | file LICENSE
URL: https://r-datatable.com, https://Rdatatable.gitlab.io/data.table, https://github.com/Rdatatable/data.table
BugReports: https://github.com/Rdatatable/data.table/issues
VignetteBuilder: knitr
VignetteBuilder: litedown
Encoding: UTF-8
ByteCompile: TRUE
Authors@R: c(
Expand Down
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ if (getRversion() >= "4.0.0") {
# version of R (and that is checked in .onLoad with error if not).
export(.rbind.data.table) # only export in R<4.0.0 where it is still used; R-devel now detects it is missing doc, #5600
}
if (getRversion() >= "3.6.0") S3method(knitr::knit_print, data.table) # else manual delayed registration from the onLoad hook
if (getRversion() >= "3.6.0") {
S3method(knitr::knit_print, data.table)
S3method(xfun::record_print, data.table)
} # else manual delayed registration from the onLoad hook
S3method(dim, data.table)
S3method(dimnames, data.table)
S3method("dimnames<-", data.table)
Expand Down
6 changes: 6 additions & 0 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
setHook(packageEvent("knitr", "onLoad"), function(...) {
registerS3method("knit_print", "data.table", knit_print.data.table, envir = asNamespace("knitr"))
})
if (isNamespaceLoaded("xfun")) {
registerS3method("record_print", "data.table", record_print.data.table, envir = asNamespace("xfun"))
}
setHook(packageEvent("xfun", "onLoad"), function(...) {
registerS3method("record_print", "data.table", record_print.data.table, envir = asNamespace("xfun"))
})
}

# Set options for the speed boost in v1.8.0 by avoiding 'default' arg of getOption(,default=)
Expand Down
6 changes: 6 additions & 0 deletions R/print.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ trunc_cols_message = function(not_printed, abbs, class, col.names){
}

# Maybe add a method for repr::repr_text. See https://github.com/Rdatatable/data.table/issues/933#issuecomment-220237965
# nocov start
knit_print.data.table = function(x, ...) {
if (!shouldPrint(x)) return(invisible(x))
NextMethod()
}
record_print.data.table = function(x, ...) {
if (!shouldPrint(x)) return(character())
NextMethod()
}
# nocov end
3 changes: 3 additions & 0 deletions inst/tests/other.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ if (loaded[["knitr"]]) {
# Which is fine and works thanks to cedta().
DT = data.table(x=1, y=2)
test(11, kable(DT), output="x.*y.*1.*2")
invisible(knit(testDir("knitr.Rmd"), quiet=TRUE))
cat(readLines("knitr.md"), sep="\n")
invisible(file.remove("knitr.md"))
}

if (loaded[["parallel"]]) {
Expand Down
9 changes: 0 additions & 9 deletions tests/knitr.R

This file was deleted.

72 changes: 0 additions & 72 deletions tests/knitr.Rout.save

This file was deleted.

15 changes: 15 additions & 0 deletions tests/litedown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!suppressPackageStartupMessages(requireNamespace("litedown", quietly = TRUE))) {
cat(readLines("litedown.Rout.mock", warn = FALSE), sep = "\n")
q("no")
}

# Load litedown and render the Rmd file
library(litedown)
litedown::reactor(comment="# ", print=xfun::record_print)
invisible(litedown::fuse("litedown.Rmd", output = "litedown.md"))

# Print the rendered markdown content
cat(readLines("litedown.md"), sep = "\n")

# Clean up
invisible(file.remove("litedown.md"))
2 changes: 1 addition & 1 deletion tests/knitr.Rmd → tests/litedown.Rmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```{r test_id, message=FALSE, results="show", echo=TRUE, warning=FALSE}
```{r, test_id, message=FALSE, results="show", echo=TRUE, warning=FALSE}
require(data.table) # print?
DT = data.table(x=1:3, y=4:6) # no
DT # yes
Expand Down
File renamed without changes.
55 changes: 35 additions & 20 deletions vignettes/_translation_links.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# 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)
.write.translation.links <- function() {
url = "https://rdatatable.gitlab.io/data.table/articles"
# this guard is needed because pkgdown::build_article does not use litedown
# https://github.com/yihui/knitr/issues/926#issuecomment-68503962
knitr = isTRUE(getOption('knitr.in.progress'))
if (knitr) {
path = knitr::current_input(TRUE)
i18n_msg = knitr::opts_current$get("i18n_msg")
} else {
path = normalizePath(litedown::get_context("input"))
i18n_msg = litedown::reactor("i18n_msg")
}
rmdfile = basename(path)
rmddir = dirname(path)
if (basename(rmddir) == "vignettes") {
lang = "en"
main_dir = rmddir
} else {
lang = basename(rmddir)
main_dir = dirname(rmddir) # should be "vignettes"
}
# search for translated rmd's with same name in subfolders
translation = dir(main_dir, recursive = TRUE, pattern = glob2rx(rmdfile))
transl_lang = dirname(translation)
transl_lang[transl_lang == "."] = "en"
if (any(transl_lang != lang)) {
link_path = file.path(url, sub("(?i)\\.Rmd$", ".html", translation))
linked_transl = sprintf("[%s](%s)", transl_lang, link_path)
linked_transl[transl_lang == lang] = lang
block = sprintf(i18n_msg, paste(linked_transl, collapse = " | "))
} else {
block = ""
}
cat(block)
}
.write.translation.links()
14 changes: 9 additions & 5 deletions vignettes/datatable-benchmarking.Rmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
---
title: "Benchmarking data.table"
date: "`r Sys.Date()`"
date: !r Sys.Date()
output:
markdown::html_format:
litedown::html_format:
options:
toc: true
number_sections: true
vignette: >
%\VignetteIndexEntry{Benchmarking data.table}
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{litedown::vignette}
\usepackage[utf8]{inputenc}
---

```{r, echo = FALSE, message = FALSE}
library(data.table)
litedown::reactor(comment = "# ")
```

<style>
h2 {
font-size: 20px;
Expand All @@ -25,9 +30,8 @@ h2 {
}
</style>

```{r echo=FALSE, file='_translation_links.R'}
```{r, echo=FALSE, results='asis', file='_translation_links.R', i18n_msg='Translations of this document are available in: %s'}
```
`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
16 changes: 5 additions & 11 deletions vignettes/datatable-faq.Rmd
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: "Frequently Asked Questions about data.table"
date: "`r Sys.Date()`"
date: !r Sys.Date()
output:
markdown::html_format:
litedown::html_format:
options:
toc: true
number_sections: true
vignette: >
%\VignetteIndexEntry{Frequently Asked Questions about data.table}
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{litedown::vignette}
\usepackage[utf8]{inputenc}
---

Expand All @@ -26,18 +26,12 @@ h2 {
}
</style>

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

```{r, echo = FALSE, message = FALSE}
library(data.table)
knitr::opts_chunk$set(
comment = "#",
error = FALSE,
tidy = FALSE,
cache = FALSE,
collapse = TRUE)
litedown::reactor(comment = "# ")
.old.th = setDTthreads(1)
```

Expand Down
3 changes: 1 addition & 2 deletions vignettes/datatable-fread-and-fwrite.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

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

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
20 changes: 14 additions & 6 deletions vignettes/datatable-importing.Rmd
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
---
title: "Importing data.table"
date: "`r Sys.Date()`"
date: !r Sys.Date()
output:
markdown::html_format
litedown::html_format
vignette: >
%\VignetteIndexEntry{Importing data.table}
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{litedown::vignette}
\usepackage[utf8]{inputenc}
---

```{r, echo = FALSE, message = FALSE}
litedown::reactor(comment = "# ")
.old.th = data.table::setDTthreads(1)
```

<style>
h2 {
font-size: 20px;
}
</style>

```{r echo=FALSE, file='_translation_links.R'}
```{r, echo=FALSE, results='asis', file='_translation_links.R', i18n_msg='Translations of this document are available in: %s'}
```
`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 All @@ -41,7 +45,7 @@ The next thing is to define what content of `data.table` your package is using.

You may also want to use just a subset of `data.table` functions; for example, some packages may simply make use of `data.table`'s high-performance CSV reader and writer, for which you can add `importFrom(data.table, fread, fwrite)` in your `NAMESPACE` file. It is also possible to import all functions from a package _excluding_ particular ones using `import(data.table, except=c(fread, fwrite))`.

Be sure to read also the note about non-standard evaluation in `data.table` in [the section on "undefined globals"](#globals)
Be sure to read also the note about non-standard evaluation in `data.table` in [the section on "undefined globals"](#globals).

## Usage

Expand Down Expand Up @@ -283,3 +287,7 @@ result <- merge(dt, other_dt, by = "x")
- **Namespace Management**: Only the functions your package explicitly imports are available, reducing the risk of function name clashes.
- **Cleaner Package Loading**: Your package's dependencies are not attached to the search path, making the loading process cleaner and potentially faster.
- **Easier Maintenance**: It simplifies maintenance tasks as upstream dependencies' APIs evolve. Depending too much on `Depends` can lead to conflicts and compatibility issues over time.

```{r, echo = FALSE, message = FALSE}
data.table::setDTthreads(.old.th)
```
Loading
Loading