This is part of a series on setting up an Arrow development environment. If you haven’t gone through part 1 on setting up C++, start there.
Installation
First, install R. There is a file you can add to the Conda environment to use R within the environment, but it will not work for now on ARM Macs because pandoc is not yet available through Conda for that platform.
Then, install R dependencies with:
pushd r
R -e "install.packages('remotes'); remotes::install_deps(dependencies = TRUE)"
popd
Configuring VS Code
To configure VS Code you’ll need to update .vscode/tasks.json
and .vscode/launch.json
.
Add the following tasks to .vscode/tasks.json
:
{
"type": "process",
"label": "Build R package",
"command": "R",
"args": [
"CMD",
"INSTALL",
".",
"--preclean",
],
"options": {
"cwd": "${workspaceFolder}/r",
"env": {
"MAKEFLAGS": "-j8"
}
},
"group": "build",
},
{
"type": "process",
"label": "Test R",
"command": "R",
"args": [
"-e",
"devtools::test()"
],
"options": {"cwd": "${workspaceFolder}/r/"},
"group": "test",
},
{
"type": "process",
"label": "Lint R",
"command": "R",
"args": [
"-e",
"lintr::lint_package()"
],
"options": {"cwd": "${workspaceFolder}/r/"},
"group": "test",
}
Next, add the following launch configuration to .vscode/launch.json
:
{
"name": "LLDB Attach to R",
"type": "lldb",
"request": "attach",
// You may need to adjust this path to your R
"program": "/Library/Frameworks/R.framework/Resources/bin/exec/R",
// Use `Sys.getpid()`
"pid": "${command:pickProcess}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
How to Use the Environment
Within VS Code
You can build the R package with:
CMD + SHIFT + B > Build R
Run all tests:
CMD + P, type “task”, then select Test R
Format and lint:
CMD + P, type “task”, then select Lint R
For using the debugger, see part 4.
From CLI
Build the R package:
pushd r
MAKEFLAGS=-j8 R CMD INSTALL . --preclean
Run tests in R console
::test() devtools
Lint (in R):
::lint_package() lintr
Format code (bash):
make style