University of Warwick
November 16, 2023
By default, messages, warnings and errors are shown in the current locale.
The language can be changed with Sys.setLanguage
:
The Weblate instance at https://translate.rx.studio provides a user-friendly interface for contributing translations.
Register through website to start translating (real name encouraged).
Select a component with less than 100% translation to start translating!
Enter the translation and “Suggest” (if unsure) or “Save and continue” (if confident).
Sidebar shows alerts and any relevant terms from glossary.
Source string location, e.g. src/main/datetime.c:581
Dedicated reviewers (leaders of translation teams) can approve translations in Weblate
https://contributor.r-project.org/translations/
General conventions
Language-specific guidelines
Bugs and wishlist items are tracked through R’s Bugzilla https://bugs.r-project.org
Contributors can help by:
An account is required to post comments or share files
Is this a valid documentation bug?
.Rd
) in GitHub mirror of SVN repo https://github.com/r-devel/r-svn/Add a comment if you think the bug should be closed, with a brief explanation.
If it is a bug what action should be taken?
Note: each comment sends email to all of R Core, avoid “+1” comments!
It can be clearer to propose specific changes, rather than describe the change in words.
Code can be included in comments via a markdown code chunk.
For example, this .Rd
snippet proposes documentation for the vfont
argument of ?text
(cf. Bug 17791)
```
\item{vfont}{\code{NULL} for the current font family, or a character
vector of length 2 for \code{\link[grDevices]{Hershey}} vector fonts.
The first element of the vector selects a typeface and the second element
selects a style. Ignored if \code{labels} is an expression.}
```
Add comment to confirm patch is fine, or suggest improvements.
It can be clearer to propose specific changes, rather than describe the change in words.
Code can be included in comments via a markdown code chunk.
For example, this .Rd
snippet proposes documentation for the vfont
argument of ?text
(cf. Bug 17791)
```
\item{vfont}{\code{NULL} for the current font family, or a character
vector of length 2 for \code{\link[grDevices]{Hershey}} vector fonts.
The first element of the vector selects a typeface and the second element
selects a style. Ignored if \code{labels} is an expression.}
```
Patch files are created by modifying a copy of the R source code, which is version controlled with Subversion.
A few options:
svn diff
to create a patch file
.diff
to commit URL
The R Dev Container is a GitHub Codespace that provides a development environment - VS Code running on Linux - that can be run in the browser.
Download the patch from Bugzilla
Create new patches directory
Upload patch downloaded from Bugzilla
Continuing in VS Code terminal, change to directory with SVN checkout
Apply the uploaded patch file
$ svn patch ../patches/patch-c-rd
U src/library/base/man/c.Rd
> applied hunk @@ -44,8 +44,8 @@ with offset -1
> applied hunk @@ -81,6 +81,12 @@ with offset -1
The line numbers in the patch are off by 1 due to changes since the patch was created.
The file can be opened in VS code for further editing
After making changes create a new patch, e.g.
The file can be downloaded from the codespace to attach with a comment on Bugzilla
Index: src/library/base/man/c.Rd
===================================================================
--- src/library/base/man/c.Rd (revision 85035)
+++ src/library/base/man/c.Rd (working copy)
@@ -43,8 +43,8 @@
\code{c} is sometimes used for its side effect of removing attributes
except names, for example to turn an \code{\link{array}} into a vector.
\code{as.vector} is a more intuitive way to do this, but also drops
- names. Note that methods other than the default are not required
- to do this (and they will almost certainly preserve a class attribute).
+ names. Note that \code{c} methods other than the default are not required
+ to strip attributes (and they will almost certainly preserve a class attribute).
This is a \link{primitive} function.
}
@@ -66,7 +66,7 @@
attribute-free vectors.
}
\examples{
-c(1,7:9)
+c(1, 7:9)
c(1:5, 10.5, "next")
## uses with a single argument to drop attributes
@@ -87,9 +87,8 @@
## but rather
c(ll, d = list(1:3)) # c() combining two lists
+## descend through lists:
c(list(A = c(B = 1)), recursive = TRUE)
-
-c(options(), recursive = TRUE)
c(list(A = c(B = 1, C = 2), B = c(E = 7)), recursive = TRUE)
}
\keyword{manip}
These are the changes that were made in the end by R Core member, Sebastian Meyer (view on GitHub mirror).
Similar to reviewing documentation bugs, but more potential actions:
Bug analysis is often the most time-consuming part
https://bugs.r-project.org/show_bug.cgi?id=17616
Good behaviour
Call:
lm(formula = uptake ~ C(Treatment, "contr.treatment"), data = CO2)
Coefficients:
(Intercept) C(Treatment, "contr.treatment")chilled
30.64 -6.86
Bad behaviour
Call:
lm(formula = uptake ~ C(Treatment, contr.treatment), data = CO2)
Coefficients:
(Intercept) C(Treatment, contr.treatment)2
30.64 -6.86
Check if the bad behaviour comes from the C
function
[1] nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled
[9] nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled
[17] nonchilled nonchilled nonchilled nonchilled nonchilled chilled chilled chilled
[25] chilled chilled chilled chilled chilled chilled chilled chilled
[33] chilled chilled chilled chilled chilled chilled chilled chilled
[41] chilled chilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled
[49] nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled
[57] nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled nonchilled chilled
[65] chilled chilled chilled chilled chilled chilled chilled chilled
[73] chilled chilled chilled chilled chilled chilled chilled chilled
[81] chilled chilled chilled chilled
attr(,"contrasts")
2
nonchilled 0
chilled 1
Levels: nonchilled chilled
debugging in: C(Treatment, contr.treatment)
debug: {
if (isFALSE(as.logical(Sys.getenv("_R_OPTIONS_STRINGS_AS_FACTORS_"))))
object <- as.factor(object)
if (!nlevels(object))
stop("object not interpretable as a factor")
if (!missing(contr) && is.name(Xcontr <- substitute(contr)))
contr <- switch(as.character(Xcontr), poly = "contr.poly",
helmert = "contr.helmert", sum = "contr.sum", treatment = "contr.treatment",
SAS = "contr.SAS", contr)
if (missing(contr)) {
oc <- getOption("contrasts")
contr <- if (length(oc) < 2L)
if (is.ordered(object))
contr.poly
else contr.treatment
else oc[1 + is.ordered(object)]
}
if (missing(how.many) && missing(...))
contrasts(object) <- contr
else {
if (is.character(contr))
contr <- get(contr, mode = "function")
if (is.function(contr))
contr <- contr(nlevels(object), ...)
contrasts(object, how.many) <- contr
}
object
}
Browse[2]>
Browse[2]>
debug: if (isFALSE(as.logical(Sys.getenv("_R_OPTIONS_STRINGS_AS_FACTORS_")))) object <- as.factor(object)
Browse[2]>
debug: if (!nlevels(object)) stop("object not interpretable as a factor")
Browse[2]>
debug: if (!missing(contr) && is.name(Xcontr <- substitute(contr))) contr <- switch(as.character(Xcontr),
poly = "contr.poly", helmert = "contr.helmert", sum = "contr.sum",
treatment = "contr.treatment", SAS = "contr.SAS", contr)
…
Browse[2]>
debug: contrasts(object) <- contr
Browse[2]> contrasts(object) <- contr
Browse[2]> contrasts(object)
2
nonchilled 0
chilled 1
Browse[2]> contrasts(object) <- "contr.treatment"
Browse[2]> contrasts(object)
chilled
nonchilled 0
chilled 1
Now isolated bug to `contrasts<-`()
contrasts<-`()
…
Browse[2]>
debug: if (is.function(value)) value <- value(nlevels(x))
Browse[2]> value(nlevels(x))
2
1 0
2 1
Browse[2]> value(levels(x))
chilled
nonchilled 0
chilled 1
Browse[2]>
We’ve found a possible root cause!
One option: create our own version of `contrasts<-`()
stats::`contrasts<-`()
C
would still use stats::`contrasts<-`()
so can’t test if it solve original problemAlternative: Build R from source! This let’s us
We can use the R Dev Container again! Instructions are in the README.
In the terminal of the GitHub codespace, make a directory using the BUILDDIR
environment variable and switch to that directory.
Run the configure script from the SVN checkout
R can be started using the VS Code command palette, opened with Ctrl/Cmd + Alt + P
A new R terminal is opened alongside the bash terminal.
Scrolling to the top, we can confirm the development version of R is being used
Edit files in the SVN checkout to make desired changes.
For example, we can edit the definition of contrasts<-`()
in src/library/stats/R/contrast.R
,
This file can be opened in VS Code using the files explorer, or from the bash terminal with
Open new R terminal to test out your changes.
A patch can be created with svn diff
as before.
This can be uploaded to Bugzilla with a comment giving a summary of your bug analysis and the proposed fix.
In some cases, some extra work may be needed:
Usually best to get feedback on proposed patch first.