reditorsupport / vscode-r Goto Github PK
View Code? Open in Web Editor NEWR Extension for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
License: MIT License
R Extension for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
License: MIT License
Greetings,
I have been watching the visual studio rtvs repo, and it looks like they have a prototype in the works for bringing rtvs over to VS Code. I'm wondering if there is any way you could work their intellisense into this extension so that we can get intellisense within R files.
Here is the link to the extension https://github.com/Microsoft/RTVS/tree/master/src/VsCode/Extension
and here is a link to the issue relating to porting it over to vscode.
There are some things added in one of the recent releases that we should consider including as VS Code tasks as well.
In particular, being able to run tests and R CMD check is ideally-suited to tasks.
I wasn't sure whether an extension can provide tasks in this way, but it appears to be possible. I don't know TypeScript well enough to implement, but here's an example of an extension that provides users with tasks: https://github.com/Microsoft/vscode-extension-samples/tree/master/task-provider-sample
I can help in terms of putting together the task definition JSONs since I'm using some in my own projects already.
HI @Ikuyadeu
I am the author of the R package for Sublime Text. I have recently started a project on language server for R. Nothing is working now, but the basic skeleton is done. My plan is to move R-Box language support based on the language server.
As vscode will be another potential client for the project, so I want to invite you to join the project. Please let me know if you are interested.
Also, inspired by JuliaEditorSupport, I have an idea to create the organization REditorSupport and move R-Box and languageserver there. Let me know if you are also interested in the organization.
For folders that use a .lintr file, it would be nice is this extension would honor those settings.
R Studio environment is very useful.
This extension need this function and output like this #15
From #23
I think it is not so difficult.
If other users want to this function, I'll implement.
I have some trouble with long input lines when using R console under Visual Studio Code with the vscode-R add-in.
In RStudio, I can do the following in an R console without any issues:
> print("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
[1] "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
However, in VSCode-R, trying the same input gives me:
> print("123456789012345678901234567890123456789012345678901234567890123456789$
[1] "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
Notice the "$" symbol at the end of the input line from VSCode-R console. The visible portion of long input lines get truncated to 76 characters. The input is all there, it's the visible part that gets truncated. The help for Base R readline command, states that the limit is 256 characters so that can't be the source of this issue.
I am not sure what the issue is but it seems that the input line character limitation is specific to vscode-R.
Changing options(width=132)
does not help and neither should it since it this option is for output lines.
I would appreciate it if someone could take a look into my report. Thank you for an excellent add-in!
Steps to Reproduce:
setting.json
// toggle caching of lint results
"r.lintr.cache": true,
// Enable lintr
"r.lintr.enabled": true,
// R executable path for lintr
"r.lintr.executable": "",
// If true, lintr exec lint_package() instead of lint()
"r.lintr.ispackage": false,
// list of linter functions
"r.lintr.linters": "default_linters",
// R path for Linux
"r.rterm.linux": "/usr/bin/R",
// R path for Mac OS X
"r.rterm.mac": "/usr/local/bin/R",
// R command line options (i.e: --vanilla)
"r.rterm.option": [
"--no-save",
"--no-restore",
"--no-site-file"
],
// R.exe path for windows
"r.rterm.windows": "C:\\Program Files\\R\\R-3.3.3\\bin\\x64\\R.exe",
// An optional encoding to pass to R when executing the file, i.e. 'source(FILE, encoding=ENCODING)'
"r.source.encoding": "UTF-8",
// Keeping focus when running
"r.source.focus": "editor"
user modified setting.json:
// R settings
"r.rterm.windows": "C:/Program Files/R/R-3.4.3/bin/x64/R.exe",
"r.lintr.enabled": false,
Good afternoon,
I can't run any R command from VSC with the R extension installed.
I installed the extension but am not able to run any command. For installing, I just downloaded from VSC marketplace and checked R path in the settings. When seeing that it was working, I uninstalled and reinstalled the extension, R, and lintr in R. I'm usually using RStudio without problem.
R, VSC and macOS are updated to the last version available.
Screen captures.zip
settings.json.zip
Mac, Version 1.12.2 (1.12.2)
platform: x86_64-apple-darwin15.6.0
arch: x86_64 // os: darwin15.6.0 //system: x86_64, darwin15.6.0
svn rev: 72570
version.string R version 3.4.0 (2017-04-21)
System Version: macOS 10.12.5 (16F73)
Kernel Version: Darwin 16.6.0
Could I suggest adding richer syntax definitions and highlighting? Something like https://github.com/randy3k/R-Extended?
With the following settings when I try to run R: lintr it tells me that the lintr package is not installed even though it is.
any(installed.packages()[, "Package"] == "lintr")
[1] TRUE
Those are default settings:
// toggle caching of lint results
"r.lintr.cache": true,
// Enable lintr
"r.lintr.enabled": true,
// R executable path for lintr
"r.lintr.executable": "",
// If true, lintr exec lint_package() instead of lint()
"r.lintr.ispackage": false,
// list of linter functions
"r.lintr.linters": "default_linters",
// R path for Linux
"r.rterm.linux": "/usr/bin/R",
// R path for Mac OS X
"r.rterm.mac": "/usr/local/bin/R",
// R command line options (i.e: --vanilla)
"r.rterm.option": [
"--no-save",
"--vanilla"
],
// R.exe path for windows
"r.rterm.windows": "C:\\Program Files\\R\\R-3.3.3\\bin\\x64\\R.exe",
// An optional encoding to pass to R when executing the file, i.e. 'source(FILE, encoding=ENCODING)'
"r.source.encoding": "UTF-8",
// Keeping focus when running
"r.source.focus": "editor",
This is what I have in user settings
"workbench.colorTheme": "Monokai",
"r.rterm.windows": "C:\\Program Files\\R\\R-3.4.2\\bin\\x64\\R.exe",
"r.lintr.executable": "C:\\Program Files\\R\\R-3.4.2\\bin\\x64\\R.exe"
In #26, It's very useful function.
Okay, I found the way to run a line (just like RStudio, its Cmd + Enter, and the run source utility is useful. However, I'm wondering about running just individual code chunks, e.g.
code_chunk <- function(x) {
cat("I am a chunk")
}code_chunk_2 <- x %>%
mutate(...) %>%
transmute(...)If I play my cursor at the beginning of line 1 with the first code_chunk, and enter C-c (aka Ctrl+c, or some other shortcut, say to run a region, like Ctrl+r) then it would run all three lines at once (the whole chunk), and not run code_chunk_2, and if this could be done without necessarily highlighting the chunk prior to running the code.
Just wondering if you might have some insight on how this could be done, or alternately if this could be implemented in an update?
Steps to Reproduce:
R: Create Terminal
Cannot find R client. Please check R path in preferences and reload.
This is my locale.json file
{
// Defines VSCode's display language.
// See https://go.microsoft.com/fwlink/?LinkId=761051 for a list of supported languages.
// Changing the value requires restarting VSCode.
"locale":"en",
"r.rterm.windows": "C:\\Program Files\\R\\R-3.4.3\\bin\\x64\\R.exe"
}
R
code and only find I just don't save my edited file.I have this in my keybindings.json
:
{
"key": "alt+enter",
"command": "r.runSelection",
"when": "editorLangId = 'r'"
}
it doesn't run selections, how do I fix it? If possible, I would request shortcut keys as a feature request
Steps to Reproduce:
.Rmd
document with citations in it.R Markdown
is selected as the highlighting language.In this case, the citations aren't recognised by the highlighting, and pairs of underscores are read as italicisation. If the citation key has an odd number of underscores, the italicisation continues past the citation on to the next underscore.
I'm running win10 fall creators update [ 1709 / 16299.15 ] + visual studio code 1.17.1 [ sep17 ] + R language extension [ 0.4.7 ]. My user settings [ %appdata%\Code\User\settings.json ] contains entry [ "r.rterm.windows": "C:\Program Files\Microsoft\R Client\R_SERVER\bin\x64\R.exe", ] to denote use of default vs17 [ 15.4.0 / 27004.2002 ] provided Microsoft R client.
With vscode open against folder containing my *.R [ and some *.Rmd, *.csv, *.md, etc ] files and one of the *.R files open with cursor sitting on a line with simple R language variable assignment i press winkey + enter to execute that line and nothing happens. If i try F1 | >R: Run Selection/Line it attempts to open a new R Terminal window, vs using the one i opened using F1 | >R: Create R terminal which does process interactively entered valid R language syntax.
I want to use lintr method of customizing linter behavior.
Tried this: "r.lintr.linters": "with_defaults(line_length_linter(100))" with no effect.
Which is the correct way to configure linting in vscode (without .lintr file)?
Steps to Reproduce:
R: lintr
from vscodeRelated issues:
I'd really like to see this extension have an R variable viewer. This is the only reason I'm stuck using RStudio or Visual Studio, as they have integrated variable viewers.
I think I could hack it out, but I'm having problems finding a way to get information from the Terminal in the current vscode API.
Had any thoughts of implementing this feature?
When I run R: Create R Terminal
it fails with the following issue:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
J:\USERS\JDKS\Data Science>& 'C:\R\bin\x64\R.exeR'
& was unexpected at this time.
J:\USERS\JDKS\Data Science>
Which is odd because in my settings I have "r.rterm.windows": "C:\\R\\bin\\x64\\R.exe"
Did I mess something up here?
how do i change the windows default r location
(with extension vim installed)
When nothing is selected, the default behavior of R: Run Selection/Line
executes the first line of the current file.
And, I suggest that after performing R: Run Selection/Line
, the cursor should move to next line(when nothing is selected) or next code block, just like in RStudio:
I find that occasionally when I execute the commands R: Run Source
(or by keyboard shortcut) and the integrated terminal open an R
session (not source my code actually) so I have to source it again.
Does it mean the code has been sent to the terminal before starting an R
session so I cannot see any command in the terminal? It really bothers me in spite of it's a small problem... 😅
And also the R: Run Selection/Line
has the same problem.:grimacing:
When running lintr
under Windows 10 with latest VS Code and R extension, the linting does not work on my system since the line (in your extension.js
)
cp.execFile(RPath, parameters, (error, stdout, stderr) => {
does produce an empty stdout
. The R command built by this line itself works when run externally, and produces linting messages to stdout
. However, when I change the line to
cp.exec(RPath + " " + parameters.join(" "), (error, stdout, stderr) => {
then linting works just fine in the R extension. Would it be possible to change the line accordingly?
I added icon 74dfc52
The icon from http://www.microsoft.com/en-us/download/details.aspx?id=35825
But this is png file from 2012 version, and not clear.
I should this icon to other file from 2015 version.
VS2012 Image Library.zip 19.4 MB
VS2013 Image Library.zip 285.6 MB
VS2015 Image Library.zip 2.9 GB
Great work on this, thank you!
One thing I find useful is to see plots and help documents in the IDE (both RStudio and R Tools for Visual Studio offer this). It would be great to have the same thing for R in VS Code.
The julia-vscode and pythonVSCode extensions both include plot panes within VS Code itself, which I guess means it's possible.
Thanks
Is there any way to create a keybinding run code from a .R file without invoking the system commands? Specifically looking for a way to run code similarly to ESS in Emacs, using C-j
and C-c
(where the first C in both cases is the Ctrl key) to send a line and chunk (paragraph), respectively. Could this be added into the extension?
Just some background: I am a new user of VSCode. Before I switched to VSCode, I am a Vim user. There is a Vim plugin called NVim-R that can covers some general functionalities for R programming in Vim. The author wrote an R package called nvimcom to handle the communication between Vim and R. I am very glad to see your extraordinary works on vscode-R. I know that the language server of R in vscode is under development. Hope it could be done soon and Intellisense could be added in the near future.
In vscode 1.17.1, the feature of folding by regions was added. Currently, I can toggle folding based on functions. I wonder if there is any way to add a customized folding marker for R, e.g. {{{
and }}}
like Powershell #region
and #endregion
described in vscode docs?
is there a way to stop ctrl+C from exiting the R terminal? In RStudio it just deletes the line which is more desirable than turning of the whole terminal
I was able to get everything running just fine on my mac.
However now that I'm at the office. I am not able to get this running on my work computer Windows 7
Hi, great little extension! One thing I'm not fond of though is the lintr integration, which imo has an incomprehensible set of defaults and is unreasonably slow.
After installing the extension, I get harassed by a box asking me to install lintr if it's not installed. Eventually I gave up and installed it, and set "r.lintr.enabled": false
in my settings.json, but it's still running things through lintr. Is there any way to disable this?
Rcpp allows to write R code in cpp block comment, like the following.
Now RStudio already support this kind of R code. I hope vscode-R can support it too.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double meanC(NumericVector x) {
int n = x.size();
double total = 0;
for(int i = 0; i < n; ++i) {
total += x[i];
}
return total / n;
}
/*** R
library(microbenchmark)
x <- runif(1e5)
microbenchmark(
mean(x),
meanC(x)
)
*/
Hey,
I have a ~/.Rprofile file that among other things contains .libPaths("~/.R/packages")
. Saving all packages in a user-defined library. This is useful for many reasons, and most things in vscode-R work well as long as I change the main startup settings to not include "vanilla":
"r.rterm.option": ["--no-save"]
But it seems that the R session that lints code is still loaded using the vanilla
option since vscode-R keeps nagging me about the linter not being installed each time I save an .R file, even if the lintr library is loaded in the console. Trying to install things in the default directory doesn't work properly when R is installed with Homebrew (probably due to this issue: Homebrew/homebrew-core#17098). But even if it would, the "install lintr" command executes install.packages("lintr") to my own library so after a successful install, it still cannot find the package.
According to man R
:
--vanilla
Combine --no-save, --no-restore, --no-site-file, --no-init-file
and --no-environ
Why do you need to run --no-site-file, --no-init-file and --no-environ? My suggestion would be to default to only --no-save and --no-restore, for both the lintr session and the console session.
Extension | Author (truncated) | Version |
---|---|---|
bracket-pair-colorizer | Coe | 0.10.14 |
vscode-markdownlint | Dav | 0.12.0 |
vsc-material-theme | Equ | 1.1.2 |
gc-excelviewer | Gra | 2.0.16 |
r | Iku | 0.5.2 |
latex-workshop | Jam | 3.10.1 |
code-settings-sync | Sha | 2.8.7 |
path-intellisense | chr | 1.4.2 |
python | ms- | 0.9.1 |
sublime-keybindings | ms- | 3.0.3 |
vscode-icons | rob | 7.19.0 |
markdown-preview-enhanced | shd | 0.3.1 |
code-spell-checker | str | 1.6.2 |
code-spell-checker-swedish | str | 0.1.1 |
It looks like data within the Dataframe Preview command is getting cached somewhere and not renewed. It doesn't look like it is happening in vscode-R , so I'll need to dig through the source of the Excel Preview extension and find it.
Now, viewer will be opened same tab, but it is little difficult to use.
These should be on side like R Studio and Markdown preview.
Now, only move in windows
I have a simple question: Is it the intended behavior that I cannot send code from R Markdown code chunks to the integrated terminal? I am returning to VS Code after having used a much earlier version of this extension, and I was thinking this was a feature. I could be confusing it with a Sublime Text extension or something else from when I last tried out various editors for R support.
If this is supposed to work, then I'll submit more information so we can try to figure out why it does not for me.
If this is not a current feature, then I'll submit my suggestion that you add it :)
Key combination Ctrl + Shift + S
is a standard shortcut for 'Save As...' dialog and it is already taken by VS Code. I suggest to use a different combination for 'R: Run Source' because the user might get a different behavior than the one expected.
Thanks for the great extension!
Hello,
My question is in the title. I would like to know if your extension 'vs-code R' accepts a 32-bit version of R or if a 64-bit version of R is required as in RTVS.
Thanks
Florent
Steps to Reproduce:
rm(list = ls())
setwd("D:\temp")
house<-read.csv("北京链家二手房全部数据.csv")
(If related)setting.json
// R.exe path for windows
"r.rterm.windows": "C:\\Program Files\\R\\R-3.3.3\\bin\\x64\\R.exe",
// R path for Mac OS X
"r.rterm.mac": "/usr/local/bin/R",
// R path for Linux
"r.rterm.linux": "/usr/bin/R",
// R command line options (i.e: --vanilla)
"r.rterm.option": [],
// An optional encoding to pass to R when executing the file, i.e. 'source(FILE, encoding=ENCODING)'
"r.source.encoding": "UTF-8",
// Keeping focus when running
"r.source.focus": "editor",
// Enable lintr
"r.lintr.enabled": true,
// list of linter functions
"r.lintr.linters": "default_linters",
// toggle caching of lint results
"r.lintr.cache": true,
// R executable path for lintr
"r.lintr.executable": "",
// If true, lintr exec lint_package() instead of lint()
"r.lintr.ispackage": false
When execute the command R:Create R terminal this don't work, the terminal goes blank, is the same for any other command.
My version:
C:\Users\xxxxx>r
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit) ...
Hello,
This package's feature you show is awesome, but I cannot use it on my Windows 7. I use conda to manage my R packages, so I have to change the R location, but it fails.
I use cmd to confirm my R location is right.
And I add the location to VS code in setting.
When I run R in VS code
BTW, I love your font show in
What's name of this font?
Thanks.
I have met issue after updated when I invoke the R terminal by ctrl+enter, there is nothing shows in the terminal. I run vscode in window 10 and R 3.4.3.
Nice extension, thank you for making it! I am using the Jupyter R-Kernel as R interpreter in your extension since it has better command completion within the VS Code terminal compared to Rterm. However, this does not work well with lintr. Would it be possible for you to let users specify the R interpreter for linting independently of the one used for the terminal?
Love this extension :)
I have found myself using multiple R terminals in VSCode. The most common case is when I want to use one to lookup documentation while I work out how to use a particular R function.
I would like to suggest that the main R terminal used by this extension be given a special name so it is easy to distinguish from other R terminals the user might have opened. Something like "R Session" or "R Workspace" maybe?
Should be a small change to here: https://github.com/Ikuyadeu/vscode-R/blob/master/src/rTerminal.ts#L9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.