-
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. -
We can now run R commands. We will use the
utils::askYesNo()
function as an example
> askYesNo("Is this a good example?")
Is this a good example? (Yes/no/cancel) Yes
[1] TRUE
- 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
prompts = getOption("askYesNo", gettext(c("Yes", "No", "Cancel"))),
> With edit (for example - change to whatever you like!):
prompts = getOption("askYesNo", gettext(c("Oh yeah!", "Don't think so", "Cancel"))),
- 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
-
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.
> askYesNo("Is this a good example?")
Is this a good example? (Oh yeah!/don't think so/cancel) Oh yeah!
[1] TRUE