1、依据 The Comprehensive R Archive Network 安装R
2、换源
nano ~/.Rprofile
options("repos" = c(CRAN="https://mirrors4.tuna.tsinghua.edu.cn/CRAN/"))
3、安装radian
sudo apt install pipx
pipx ensurepath
cd ~ && mkdir .pip && cd .pip
touch pip.conf && nano pip.conf
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
timeout = 6000
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
pipx install radian
4、安装系统依赖
sudo apt install gcc g++ make cmake gfortran build-essential libcurl4-openssl-dev libssl-dev libxml2-dev libcairo2-dev libtiff-dev libxtst-dev libpng++-dev libbz2-dev
5、安装R依赖包
install.packages("languageserver")
install.packages("httpgd")
6、依据 Running Visual Studio Code on Linux 安装VSCode
7、配置VSCode
(1) 安装 R 和 R Debugger 插件
(2) Ctrl+K Ctrl+S 打开键盘快捷方式(JSON)
// begin of R language shortcuts
[{
"key": "ctrl+shift+m",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'",
"args": {
"snippet": " %>% "
}
},
{
"key": "ctrl+enter",
//"command": [ "python.execSelectionInTerminal", "cursorDown" ],
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && editorLangId == 'python'"
}
]
(3) Ctrl+,
搜索 rpath.linux 填写 /usr/bin/R
搜索 rterm.linux 填写 /home/$USER/.local/bin/radian
注意:将$USER更改为用户名
搜索 httpgd 勾选
搜索 r.bracketed 勾选