Home > Development Tools > VSCode > body text

How to write R language in vscode

藏色散人
Release: 2020-04-03 09:25:06
Original
10993 people have browsed it

How to write R language in vscode

How to write r language in vscode?

Install R extension plug-in

Recommended learning: vscode tutorial

(1) R. This plug-in is the core plug-in for R in VS Code, with functions such as syntax highlighting, basic code snippets, and code execution. For example, you can select certain lines of content in the editor and then use ctrl enter to send the code to the terminal for execution.

How to write R language in vscode

R plug-in

After the R plug-in is installed, it still needs to be configured for normal use, mainly to configure the installation path of the R core program R.exe.

How to write R language in vscode

Configure R path

Right-click the R icon on the desktop and click "Open the location of the file" to quickly locate the installation path of the R program , copy the path to the configuration bar, configure it to be automatically saved, restart VS Code, and start using VS Code to write and debug R programs. Note that when configuring the path, don’t forget to add R.exe after the path, that is, C:\Program Files\R\R-3.6.1\bin\x64\R.exe

How to write R language in vscode

Find the installation path

How to write R language in vscode

Copy the R installation path

2. R LSP Client. LSP stands for Language Server Protocol. With it, you can complete code, view function definitions, and preview parameters.

How to write R language in vscode

R LSP Client

But to make it effective, you need to install the languageserver package in R. Only by installing this package can you realize the interaction between R and the editor. Synchronize.

Click on the file, create a new file, and enter the following content:

install.packages("languageserver")
Copy after login

Save the file as a file with the .R suffix, and VS Code will automatically recognize it as R code. Position the mouse on the statement, use the ctrl enter shortcut key to run the statement, and install the R package. You will be prompted to select an image source. We select a domestic image source and confirm.

How to write R language in vscode

Writing R program

How to write R language in vscode

Domestic mirror source

3. Now you can use it freely VS Code is used to write R code. Of course, there are more R plug-ins waiting for you to try, such as radian, custom shortcut keys, etc. You can explore the installation methods by yourself, so I won’t introduce them one by one here.

The above is the detailed content of How to write R language in vscode. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template