Skip to content

Commit 4502226

Browse files
20250614 - connecting to R
1 parent 989b934 commit 4502226

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

vsCode.Rmd

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Visual Studio Code"
2+
title: "Visual Studio Code (VS Code)"
33
output:
44
html_document:
55
code_folding: show
@@ -13,10 +13,11 @@ knitr::opts_chunk$set(
1313
class.source = "fold-show")
1414
```
1515

16-
# Tips and Tricks
16+
# Tips and Tricks {#tipsAndTricks}
1717

1818
1. You can view the source code side-by-side with the Preview (after selecting the code type in the bottom right):
1919
![Visual Studio Code](images/vsCode.png)
20+
1. To create personalized CSS commands in VS Code, see [here](https://devpsylab.github.io/DataAnalysis/markdown.html#css).
2021
1. To wrap code around the selected text (https://stackoverflow.com/a/73344832/2029527; archived at https://perma.cc/P5JA-7DBC):
2122
1. Press `Ctrl`+`Shift`+`p`
2223
1. Type and select "Open Keyboard Shortcuts (JSON)"
@@ -36,9 +37,9 @@ knitr::opts_chunk$set(
3637
1. Save the `keybindings.json` file.
3738
1. Select the text you want to wrap, and press `Alt`+`Shift`+`e`
3839

39-
# Example Code Snippets
40+
# Example Code Snippets {#exampleCodeSnippets}
4041

41-
## Template
42+
## Template {#template}
4243

4344
```
4445
[
@@ -53,7 +54,7 @@ knitr::opts_chunk$set(
5354
]
5455
```
5556

56-
## `\begin{equation}...\end{equation}`
57+
## `\begin{equation}...\end{equation}` {#equation}
5758

5859
```
5960
[
@@ -68,12 +69,32 @@ knitr::opts_chunk$set(
6869
]
6970
```
7071

71-
# Connect to `R`
72+
# Connect to `R` {#connectToR}
73+
74+
1. Install `R` using the initial setup instructions described here: https://devpsylab.github.io/DataAnalysis/R.html#setup
75+
1. Install the [`R` extension](https://marketplace.visualstudio.com/items?itemName=REditorSupport.r) for `VSCode`
76+
1. Go into the `R` extension settings
77+
1. Set the `rpath` variable to be blank
78+
1. Set the `rterm` variables (e.g., `r.rterm.windows`) to be blank
79+
1. Close VS Code
80+
1. Set VS Code to Run as Administrator by default
81+
1. Open VS Code as Administrator
82+
1. Launch the R terminal (Ctrl+Shift+P → "R: Create R terminal").
83+
84+
VS Code extensions to install:
85+
- [Quarto](https://marketplace.visualstudio.com/items?itemName=quarto.quarto)
86+
87+
`R` packages to install:
88+
- `install.packages(c("languageserver","httpgd"))`
89+
- `languageserver` is used for syntax highlighting and code completion
90+
- `httpgd` is used for plotting in VS Code
91+
92+
## Old Instructions {#oldInstructions}
7293

7394
Follow the instructions here to connect `VSCode` to `R`:
7495
https://stackoverflow.com/a/66069540/2029527 (archived at https://perma.cc/FCF5-26BT)
7596

76-
1. Install `R` using the inital setup instructions described here: https://devpsylab.github.io/DataAnalysis/R.html#setup
97+
1. Install `R` using the initial setup instructions described here: https://devpsylab.github.io/DataAnalysis/R.html#setup
7798
1. Install the `R` extension for `VSCode`
7899
1. Go into the `R` extension settings
79100
1. Set the `R` path to the path of your `R` installation:

0 commit comments

Comments
 (0)