Skip to content

R Contribution Workflow

1. Example Contribution Workflow using the R Dev Container:

  • To start working in R we will click on R:(not attach) which is in the bottom right of the VSCode window. This will open an R terminal for us.

    alt text

    alt text

  • We can now run R commands. We will use the utils::askYesNo() function as an example

    alt text

    > askYesNo("Is this a good example?")
    Is this a good example? (Yes/no/cancel) Yes
    [1] TRUE 

2. Editing Source Code

  • Edit the source code of utils::askYesNo() to change the default options. The source code can be found in $TOP_SRCDIR/src/library/utils/R/askYesNo.R.
  • You can redirect to that file using
    code $TOP_SRCDIR/src/library/utils/R/askYesNo.R
    

> Before edit: alt text

askYesNo.R
    prompts = getOption("askYesNo", gettext(c("Yes", "No", "Cancel"))),

> With edit (for example - change to whatever you like!):

alt text

askYesNo.R
    prompts = getOption("askYesNo", gettext(c("Oh yeah!", "Don't think so", "Cancel"))),

3. Rebuild R

  • We can re-build R with our changes. Since we have only modified the utils package, rebuilding R will only re-build the utils package.
  • First we need to be inside $BUILDDIR.
  • Quit R with q() or by closing the R terminal.
  • In the bash terminal, change to the build directory:
    cd $BUILDDIR
    
  • Now run the make command to rebuild R with the changes you made in step 2. This will be much faster than the full build!
    make
    

alt text

  • Optionally run make check to run R's test suite with your local changes. You may skip this step while you are iterating on a bug fix or other development, until you are ready to create a patch.

  • To use the re-built R, simply open a new R terminal.

4. Cross check and Re-running Code

  • Check the edit has worked as expected by re-running the example code: alt text
    > askYesNo("Is this a good example?")
    Is this a good example? (Oh yeah!/don't think so/cancel) Oh yeah!
    [1] TRUE