diff --git a/vignettes/_translation_links.R b/vignettes/_translation_links.R new file mode 100644 index 000000000..5e09f447c --- /dev/null +++ b/vignettes/_translation_links.R @@ -0,0 +1,26 @@ +# 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)) { + sprintf( + fmt, paste(collapse = " | ", sprintf( + "[%s](%s)", + transl_lang[transl_lang != lang], + file.path(url, sub("(?i)\\.Rmd$", ".html", translation[transl_lang != lang])) + ))) + } else "" + knitr::asis_output(block) +} diff --git a/vignettes/datatable-benchmarking.Rmd b/vignettes/datatable-benchmarking.Rmd index 733b4914d..1a47d9530 100644 --- a/vignettes/datatable-benchmarking.Rmd +++ b/vignettes/datatable-benchmarking.Rmd @@ -25,9 +25,9 @@ h2 { } -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. diff --git a/vignettes/datatable-faq.Rmd b/vignettes/datatable-faq.Rmd index 4c6f4c633..e238082dd 100644 --- a/vignettes/datatable-faq.Rmd +++ b/vignettes/datatable-faq.Rmd @@ -26,10 +26,6 @@ h2 { } -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-faq.html) - ```{r, echo = FALSE, message = FALSE} library(data.table) knitr::opts_chunk$set( @@ -41,6 +37,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + The first section, Beginner FAQs, is intended to be read in order, from start to finish. It's just written in a FAQ style to be digested more easily. It isn't really the most frequently asked questions. A better measure for that is looking on Stack Overflow. This FAQ is required reading and considered core documentation. Please do not ask questions on Stack Overflow or raise issues on GitHub until you have read it. We can all tell when you ask that you haven't read it. So if you do ask and haven't read it, don't use your real name. diff --git a/vignettes/datatable-importing.Rmd b/vignettes/datatable-importing.Rmd index 21e42b67c..5c030af09 100644 --- a/vignettes/datatable-importing.Rmd +++ b/vignettes/datatable-importing.Rmd @@ -15,9 +15,9 @@ h2 { } -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/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. diff --git a/vignettes/datatable-intro.Rmd b/vignettes/datatable-intro.Rmd index d32a25eb9..b5db5c9f4 100644 --- a/vignettes/datatable-intro.Rmd +++ b/vignettes/datatable-intro.Rmd @@ -9,10 +9,6 @@ vignette: > \usepackage[utf8]{inputenc} --- -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-intro.html) - ```{r, echo = FALSE, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -25,6 +21,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + This vignette introduces the `data.table` syntax, its general form, how to *subset* rows, *select and compute* on columns, and perform aggregations *by group*. Familiarity with the `data.frame` data structure from base R is useful, but not essential to follow this vignette. *** diff --git a/vignettes/datatable-joins.Rmd b/vignettes/datatable-joins.Rmd index a35f78bb2..f296940bd 100644 --- a/vignettes/datatable-joins.Rmd +++ b/vignettes/datatable-joins.Rmd @@ -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: diff --git a/vignettes/datatable-keys-fast-subset.Rmd b/vignettes/datatable-keys-fast-subset.Rmd index 6f77c3de2..a44e6dc06 100644 --- a/vignettes/datatable-keys-fast-subset.Rmd +++ b/vignettes/datatable-keys-fast-subset.Rmd @@ -9,10 +9,6 @@ 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, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -24,6 +20,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + This vignette 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, add/modify/delete columns *by reference* in `j` and group by using `by`. If you're not familiar with these concepts, please read the vignettes [`vignette("datatable-intro", package="data.table")`](datatable-intro.html) and [`vignette("datatable-reference-semantics", package="data.table")`](datatable-reference-semantics.html) first. *** diff --git a/vignettes/datatable-programming.Rmd b/vignettes/datatable-programming.Rmd index 93c6dc556..9264e181c 100644 --- a/vignettes/datatable-programming.Rmd +++ b/vignettes/datatable-programming.Rmd @@ -9,10 +9,6 @@ vignette: > \usepackage[utf8]{inputenc} --- -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-programming.html) - ```{r init, include = FALSE} require(data.table) knitr::opts_chunk$set( @@ -24,6 +20,9 @@ knitr::opts_chunk$set( ) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` ## Introduction diff --git a/vignettes/datatable-reference-semantics.Rmd b/vignettes/datatable-reference-semantics.Rmd index b6d895af1..750bb9b4e 100644 --- a/vignettes/datatable-reference-semantics.Rmd +++ b/vignettes/datatable-reference-semantics.Rmd @@ -9,10 +9,6 @@ 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, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -23,6 +19,11 @@ knitr::opts_chunk$set( collapse = TRUE) .old.th = setDTthreads(1) ``` + +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + 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. *** diff --git a/vignettes/datatable-reshape.Rmd b/vignettes/datatable-reshape.Rmd index bf7b18e53..41691f386 100644 --- a/vignettes/datatable-reshape.Rmd +++ b/vignettes/datatable-reshape.Rmd @@ -9,10 +9,6 @@ vignette: > \usepackage[utf8]{inputenc} --- -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-reshape.html) - ```{r, echo = FALSE, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -24,6 +20,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + This vignette discusses the default usage of reshaping functions `melt` (wide to long) and `dcast` (long to wide) for *data.tables* as well as the **new extended functionalities** of melting and casting on *multiple columns* available from `v1.9.6`. *** diff --git a/vignettes/datatable-sd-usage.Rmd b/vignettes/datatable-sd-usage.Rmd index 2f91f0bb1..069e692cb 100644 --- a/vignettes/datatable-sd-usage.Rmd +++ b/vignettes/datatable-sd-usage.Rmd @@ -21,10 +21,6 @@ vignette: > } -Translations of this document are available in - -* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-sd-usage.html) - ```{r, echo = FALSE, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -39,6 +35,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + This vignette will explain the most common ways to use the `.SD` variable in your `data.table` analyses. It is an adaptation of [this answer](https://stackoverflow.com/a/47406952/3576984) given on StackOverflow. # What is `.SD`? diff --git a/vignettes/datatable-secondary-indices-and-auto-indexing.Rmd b/vignettes/datatable-secondary-indices-and-auto-indexing.Rmd index 7be917032..0de675247 100644 --- a/vignettes/datatable-secondary-indices-and-auto-indexing.Rmd +++ b/vignettes/datatable-secondary-indices-and-auto-indexing.Rmd @@ -9,10 +9,6 @@ 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, message = FALSE} require(data.table) knitr::opts_chunk$set( @@ -24,6 +20,10 @@ knitr::opts_chunk$set( .old.th = setDTthreads(1) ``` +```{r echo=FALSE, file='_translation_links.R'} +``` +`r .write.translation.links("Translations of this document are available in: %s")` + This vignette assumes that the reader is familiar with data.table's `[i, j, by]` syntax, and how to perform fast key based subsets. If you're not familiar with these concepts, please read the [`vignette("datatable-intro", package="data.table")`](datatable-intro.html), [`vignette("datatable-reference-semantics", package="data.table")`](datatable-reference-semantics.html), and [`vignette("datatable-keys-fast-subset", package="data.table")`](datatable-keys-fast-subset.html) vignettes first. ***