Cover Pic by @BLACKmeow
213 words
1 minutes
Jupyter中使用R
- Cover Pic by @リョンsan
简介
- Rstudio固然不错,但不可能只用R吧
- 虽然Rstudio也支持Python了,但正经人谁会用Rstudio写Python呢
- 习惯以后还是随手点开VScode然后新建.ipynb切R内核写代码爽哈,一点都不比RMarkdown差
安装
Jupyter
- 安装Jupyter参考:Installing Jupyter
- JupyterLab(Web版IDE)
# 安装
pip install jupyterlab
# 打开
jupyter lab- Jupyter Notebook(纯Notebook)
# 安装
pip install notebook
# 打开
jupyter notebookR kernel
- 安装R内核参考:IRkernel/IRkernel
- 打开R终端,输入以下代码即可
install.packages('IRkernel')
IRkernel::installspec()
jupyter labextension install @techrah/text-shortcuts 快捷键
- 个人设置的快捷键
[
{
"key": "ctrl+cmd+[Minus]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'|'Rmd'|'ipynb'",
"args": {
"snippet": " <- "
}
},
{
"key": "ctrl+cmd+[Equal]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'|'Rmd'|'ipynb'",
"args": {
"snippet": " %>% "
}
},
{
"key": "ctrl+cmd+[IntlYen]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'|'Rmd'|'ipynb'",
"args": {
"snippet": " |> "
}
},
{
"key": "ctrl+cmd+5",
"command": "type",
"args": {
"text": " %in% "
}
]