Brief History of R

1992: Robert Gentleman and Ross Ihaka develop an early version of R for teaching.

1995: Martin Mächler (ETH Zurich) persuades Robert and Ross to release R under a GNU public license.

  • R developed more openly
  • User community grows to millions world wide


30 years as an open source project: How can the community help to sustain R?

Localization

Localization

By default, messages, warnings and errors are shown in the current locale.

The language can be changed with Sys.setLanguage:

> Sys.setLanguage("es")
> months[1]
Error in months[1] : objeto de tipo 'closure' no es subconjunto

If no translation is available, the English is shown:

> help(c("mean", "sd"))
Error en help(c("mean", "sd")): 
  'topic' should be a name, length-one character vector or reserved word

PO Files

In the R sources, translations are stored in .po files, e.g.:

utils/po/R-es.po
msgid "no documentation for %s found in package %s"
msgstr "no se ha encontrado documentación para %s en el paquete %s"

msgid "document not found"
msgstr "El documento no se ha encontrado"

utils/po/R-es.po
msgid "'topic' should be a name, length-one character vector or reserved word"
msgstr ""

msgid "No documentation for %s in specified packages and libraries:"
msgstr ""

Translation via Weblate

The Weblate instance at https://translate.rx.studio set up by Gergely Daróczi provides a user-friendly interface for contributing translations.

Screenshot of Weblate hompage, showing three translation projects with some translation coverage summary statistics including % translated and number of unfinished strings.

The R Project for Statistical Computing

Screenshot of the R Project for Statistical Computing project on weblate, with per package translation coverage summaries
  • Most packages have two components for strings in R and C files
  • Also translate strings in the Windows and Mac GUIs

Languages tab

Screenshot of the language tab for the R Project for Statistical Computing project, with per language translation coverage summaries
  • 27 languages in current release of R, including Spanish and Brazilian Portuguese

Translation interface

Screenshot of the translation interface for translation of a specific string. Shows the english message with an empty box to type the Spanish translation
  • Enter the translation and “Suggest” (if unsure) or “Save and continue” (if confident).

  • Sidebar shows alerts and any relevant terms from glossary.

Machine translation

Screenshot of the translation interface for translation of a specific string. Shows the english message with an empty box to type the Spanish translation
  • “Clone to translation” will copy and mark as “needs editing”
  • “Accept” will accept suggestion, save and continue

Latin American Contributions

Top: Translators on Weblate. Bottom: Translators at LatinR 2023

  • Many Weblate contributors from the LatinR community
  • Several joined via contributor events, e.g., at LatinR 2022 - 2024
  • Big improvement in base R translations since Weblate set up in 2022:
    • Spanish: from 24% to 100% translated
    • Brazilian Portuguese: from 48% to 85% translated

Further work

  • Translation of messages in recommended packages:
    • Spanish: 85% translated
    • Brazilian Portuguese: 57% translated
  • Updating translations as source messages change
    • R Core Team update 1-2 times a year


Register on https://translate.rx.studio to start translating!
(Real name encouraged.)

R Code and Documentation

Bugs Reports and Feature Requests

Contributors can help in several ways:

  • Reviewing bug reports
  • Creating a “reprex”
  • Debugging R code
  • Discussing how to fix
  • Developing a patch
  • Testing a patch
  • Debugging C code

Warning

Contributions on the right require building R from source

Building R as a Barrier to Contribution

  • A lot of information to digest
  • Hard to trouble-shoot issues
  • Many pre-requisities to install
  • Can interfere with existing R installation

Caution

Can be a big time sink for ad-hoc contributors!

R Dev Container

The R Dev Container provides a development environment that can be run in the browser:

R Dev Container Features

  • Launch with GitHub Codespaces (60 hours/month free usage)
  • Fixed Linux (Ubuntu) environment, isolated from local system
    • Pre-requisites for building R installed
  • Docs with mini tutorials:

R Contribution Workflow

R Contribution Workflow: Build R

Checkout R Sources I

Checkout R Sources II

Create and Move to Build Directory

Configure the Build I

Configure the Build II

Build R!

Basic check I

Basic check II

Use R-devel in R terminals

R Contribution Workflow: Edit Source

Bug 7084: The Problem

text() recycles coordinate pairs when there are more labels than points

plot(1:7); text(1:2, 2:4, LETTERS[1:4])

Bug 7084: Outline Solution

The comments on the original bug report suggest an outline solution:

if (length(labels) > (n <- max(length(x), length(y))) && n >= 1) {
   ## use labels[1:n]  and warn about length(labels) >= .. or "omitting labels[...]"
}
if (length(labels) < n) { 
  ## recycle labels to length `n`  without a warning
}

Start R I

Start R II

Explore text()

Get methods

Finding the Source with the r-svn GitHub Mirror I

Finding the Source with the r-svn GitHub Mirror II

Finding the Source with the r-svn GitHub Mirror III

Debugging text.default()

> debug(text.default)
> plot(1:7); text(1:2, 2:4, LETTERS[1:4])
debugging in: text.default(1:2, 2:4, LETTERS[1:4])
debug: {
    if (!missing(y) && (is.character(y) || is.expression(y))) {
        labels <- y
        y <- NULL
    }
    x <- xy.coords(x, y, recycle = TRUE, setLab = FALSE)
    labels <- as.graphicsAnnot(labels)
    if (!is.null(vfont)) 
        vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), 
            fontindex = pmatch(vfont[2L], Hershey$fontindex))
    .External.graphics(C_text, x, labels, adj, pos, offset, vfont, 
        cex, col, font, ...)
    invisible()
}
Browse[1]> 

Press Enter to step through the code

debug: if (!missing(y) && (is.character(y) || is.expression(y))) {
    labels <- y
    y <- NULL
}
Browse[1]> 
debug: x <- xy.coords(x, y, recycle = TRUE, setLab = FALSE)
Browse[1]> 
debug: labels <- as.graphicsAnnot(labels)
Browse[1]>

Test code at this point

Browse[1]> x
$x
[1] 1 2 1

$y
[1] 2 3 4

$xlab
NULL

$ylab
NULL
  • The labels are already recycled to length n
  • Our warnings should be based on x rather than the original arguments

Return to the Source File

Screenshot of the home page for R's Bugzilla.

Edit the Code

Screenshot of the home page for R's Bugzilla.

Edit the Documentation

Screenshot of the home page for R's Bugzilla.

R Contribution Workflow: Rebuild R

Quit R

Screenshot of the home page for R's Bugzilla.

Rebuild R

Screenshot of the home page for R's Bugzilla.

Test reprex

Screenshot of the home page for R's Bugzilla.

R Contribution Workflow: Run check

Basic check

Screenshot of the home page for R's Bugzilla.

Fail!

Screenshot of the home page for R's Bugzilla.

Look at test output

Screenshot of the home page for R's Bugzilla.

Run test code

Screenshot of the home page for R's Bugzilla.

R Contribution Workflow: Further edits

Further edits

Screenshot of the home page for R's Bugzilla.

R Contribution Workflow: Rebuild again

R Contribution Workflow: Run check again

Full check

Screenshot of the home page for R's Bugzilla.

R Contribution Workflow: Create patch

Create patch

Screenshot of the home page for R's Bugzilla.

Download patch

Screenshot of the home page for R's Bugzilla.

View patch

Index: src/library/graphics/R/text.R
===================================================================
--- src/library/graphics/R/text.R   (revision 88304)
+++ src/library/graphics/R/text.R   (working copy)
@@ -27,6 +27,16 @@
    labels <- y; y <- NULL
     }
     x <- xy.coords(x,y, recycle = TRUE, setLab = FALSE)
+
+    if (is.language(labels)) {
+        labels <- as.expression(labels)
+    }
+
+    if (length(labels) > (n <- length(x$x)) && n >= 1) { 
+        labels <- labels[1:n]
+        warning("length(labels) > max(length(x), length(y)). labels truncated to length ", n, ".")
+    }
+
     labels <- as.graphicsAnnot(labels)
     if (!is.null(vfont))
         vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface),
Index: src/library/graphics/man/text.Rd
===================================================================
--- src/library/graphics/man/text.Rd    (revision 88304)
+++ src/library/graphics/man/text.Rd    (working copy)
@@ -24,7 +24,7 @@
     language objects (names and calls) to expressions, and vectors and
     other classed objects to character vectors by \code{\link{as.character}}.
     If \code{labels} is longer than \code{x} and
-    \code{y}, the coordinates are recycled to the length of \code{labels}.}
+    \code{y}, \code{labels} is truncated to \code{max(length(x), length(y))}.}
   \item{adj}{one or two values in \eqn{[0, 1]} which specify the x
     (and optionally y) adjustment (\sQuote{justification}) of the
     labels, with 0 for left/bottom, 1 for right/top, and 0.5 for

Bug 7084: A Good First Issue

Bug 7084 is an example of a good first issue:

  • There is a simple reproducible example.
  • An R Core developer (Martin Maechler) agrees it is a bug.
  • There is an outline solution approved by the R Core developer.
  • The fix only requires editing R code.

Finding Good First issues

Check out the tips in this 10-minute video (or view slides)

You can also attend an R Contributor Office hour, next up

  • APAC: Thu 11 Dec, 2:30 - 3:30pm UTC+11
  • EMEA: Thu 11 Dec, 10:00 - 11:00am UTC
  • AMER: Thu 11 Dec, 12:00 - 1:00pm UTC-8

Or check the #getting-started channel on the R Contributor Slack.

R Dev Days

Top: Contributors at R Dev Day @ RSECon25

R Dev Days are events to work on contributions to R:

  • Translations
  • Bug fixes/feature requests
  • Supporting infrastructure

Plan to run hybrid in future, next up R Dev Day @ New Zealand 2025, 16-17 Dec

  • Stream 1 - NZ / Americas
  • Stream 2 - NZ / Asia-Pacific

https://contributor.r-project.org