A containerised development environment for editing and compiling the R source code. The environment contains the VSCode IDE and tools needed to compile R.
You can run this environment on GitHub using codespaces
Click on the 'Open in GitHub Codespaces' button and then click the green 'Create Codespace' button.
The codespace setup screen will then be shown. Starting the container may take a minute or so.
You will be taken to a VSCode editor within your browser.
Create a file in VS Code ending with a .R extension. You can create new files by clicking on the new file icon in VS Code.
Open the file by clicking on the filename. You should see R:(not attached) in the bottom bar.
Click on the R:(not attached) button to launch R in the terminal. You can then send code from the .R file to the R terminal by pressing cmd/ctrl + enter.
-
Environment Variables
-
svn checkout
-
cd to BUILDDIR
- We need to change our directory to R build directory(BUILDDIR) to build and configure our R source code.
- First we will create a directory using env var BUILDDIR.
mkdir -p $BUILDDIR
- Then we can change directory from root to $BUILDDIR one.
cd $BUILDDIR
-
configure source code
-
After we change directory to BUILDDIR we can configure and build R.
-
CMD
"$TOP_SRCDIR/configure" --enable-R-shlib --without-recommended-packages make sudo make install
-
The configure cmd prepares for building R, creating files and folders inside the BUILDDIR directory.
-
Output : We get file structure something like this after using configure command.
-
-
After having built the current development version of R, we can now make changes in source code and make our contributions.
-
Example Contribution Workflow using DevContainer:
-
To start working in R we will click on
R:(not attach)
option which is in the bottom right of our R-dev codespace. It will open 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
.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"))),
-
Re-build the utils package (we only need to re-build the part we have modified). We can rebuild the package by following simple steps
-
First we need to be inside $BUILDDIR, for that we can change directory to
cd $BUILDDIR
. -
After that we can run cmd
make
andsudo make install
in a series. -
This will re-build any parts of R that have changed, in this case only re-building the utils package, then re-install R. If we open a new R terminal we will see our changes getting reflected.
-
-
Check the edit has worked as expected by re-running the example code:
> askYesNo("Is this a good example?") Is this a good example? (Oh yeah!/don't think so/cancel) Oh yeah! [1] TRUE