I would like to use the R environment I installed with conda inside Visual Studio Code (on Macos). First I installed R with conda.
But how do I use/activate the environment in Visual Studio Code? In the settings I can't find the equivalent to "Python: Select Interpreter" or "python.venvPath"
Thanks!
R support in VSCode is handled by a 3rd party extension. The most popular one is R by Yuki Ueda and there is also R Tools by Mikhail Arkhipov
For both of these, you can change the R interpreter to use in the settings.
However, there is no built-in support for Anaconda, mostly because it isn't that popular or necessary in the R community. Most people use the standard R installation instead and most help resources are written for that type of installation: https://cloud.r-project.org/bin/macosx/
It has been 2 years since this entry and the extension still doesn't support conda environments.
For my configuration (I've R installed in a conda environment), I found a pretty painless work around:
open 'vscode'
install the extension and configure it as suggested using the conda paths for both R and, if you have it installed, radian
close 'vscode'
open a terminal
activate your conda environment
start vscode from your terminal using code
After this, everything seems to be up and running correctly. You can start an R terminal using the command palette and, as you run your code, you should be able to see all the information about the environment and namespaces as well as your plots.
Related
Is there any possibility how can I change version of R studio by a command ? Let's say I have several versions of R in my computer. Is there any possibility how can I switch between them without going to Tools -> Global options but use some command in console instead?
I am developing R packages for an internal use applications at work. Unfortunately, not everybody is on the same version of R. I want to build Windows binaries of my package to support multiple versions, for example, 3.6.x and 4.0.x R.
I can easily do this by building the package (I use devtools::build(binary = TRUE)), and then change the R version in RStudio, restart, and run again. But this gets very tedious.
Is there a way to streamline this (e.g., my own custom function to build both at once)? I imagine some CI/CD thing is probably best, but this solution would have to be limited to what I can run locally.
Don't do it in RStudio, write a script to do it. It would have commands like these:
/path/to/R3.6.3/R CMD INSTALL --build /path/to/yourpackage
mv yourpackage.*.zip /path/for/R3.6users
/path/to/R4.0.3/R CMD INSTALL --build /path/to/yourpackage
mv yourpackage.*.zip /path/for/R4.0users
You don't need a lot of builds; only the first two parts of the version number (e.g. 3.6 or 4.0) need to match the target system.
You could implement this script in R using system() calls, but it's probably simpler to do it using one of the Windows script languages (.bat or .cmd or whatever).
We have our R and RStudio Desktop running on individual users Windows 7 desktops and all the users are getting the required packages from our local R package repository. No, i am trying to see if there is a way to block users from access to external CRAN repository mirrors.
Editing "C:\Program Files\R\R-3.3.2\etc\repositories" files and making CRAN point to our local repository URL is helpful but this will only work as long as users are not trying to exercise R GUI Packages-> install packages or set CRAN mirrors options.(CRAN variable is getting over ridden as and when R GUI options are exercised. )
This is the reason i am truing to see if there is a way to disable R GUI and/ or R Studio Package install GUI options?
I didnt find any help how to do it on R GUI without modifying the source code, but RStudio seem to have an environment variable which is supposed to disable this option but is not working for me.
As per this link setting "RSTUDIO_DISABLE_PACKAGES" environment variable should do the trick but setting this variable to 1 on below locations doesnt do anything.
C:\Program Files\R\R-3.3.2\etc\Renviron.site
C:\Program Files\R\R-3.3.2\etc\x64.Renviron.x64
Also, I found below text on RStudio admin guide but don't know what are the equivalent files and folders for windows environment and whether or not this is applicable to RStudio desktop
/etc/rstudio/rsession.conf
allow-package-installation=0
RAndFriends, which includes all the items needed to run RExcel, includes just R 2.15.2.
I am currently using the latest version of R but rcom 2.3.1 and rscproxy 2.0.5, which I am currently using, do not allow me to start an R server within Excel.
Setting foreground R server whithin Excel returns a fatal error and R rejects any connection with Excel via rcom.
I get two error messages:
R Server not available
There seems to be no R process connected to Excel
The main difference with a running RExcel session is that in the latter you may see rscproxy and rcom to be loaded when you start a RExcel session.
Is there anyone who is currently using RExcel with R 3.0.1 who can explain me how he succeeded in running it (step by step)?
Found it on statconn's Wiki section.
Assuming you have a suitable version of R installed, the following steps are necessary to install RExcel and the infrastructure. You need to be logged into Windows with administrator privileges to do this!
You also need to follow these instructions if you upgrade R, i.e. you install a new release of R after you have installed RExcel.
Download the statconn DCOM server and execute the program you downloaded.
Start R as administrator (on Windows 7 you need to right-click the R icon and click the corresponding item).
In R, run the following commands (you must start R as administrator to do this).
Commands:
install.packages(c("rscproxy", "rcom"), repos = "http://rcom.univie.ac.at/download", lib = .Library)
library(rcom)
comRegisterRegistry()
Now you have rcom installed, but RExcel is not installed yet.
To install RExcel: download the RExcel installer and run this installation program. Installing RExcel this way will set the background server of R as the default R server for RExcel. You can change this in the configuration settings in R. If you want to set the foreground server as the default site wide server, there is an appropriate option in one of the dialogs of the installation.
The RExcel installer modifies one of the configuration files of R, the file Rprofile.site, usually found at a location like C:\Program Files\R\R-2.13.1\etc\Rprofile.site.
If you do not install RExcel and want the package rcom to be loaded into R each time you start it, you have to add the line
library(rcom)
to Rprofile.site. You have to start your editor as administrator to be able to modify this file.
I thint that focus of those instuctions are on "Assuming you have a suitable version of R installed". R 3.0.1 do not work with RExcel.
I have noticed all development of Rmetrics products have ceased development since Diethelm Wuertz untimely passing, some of his associates on the team maintain it, but further development stopped abruptly after Diethelm Wuertz the project leader and main inspiration behind the team, died in a car accident in 2015, that is how long it has been since any serious development has occurred on Rexcel and all the range of Rmetric products, it is a real tragedy they are still cutting edge 6 years after Diethelm's passing, he would be sad to see his legacy slowly die. I am looking at xlwings and converting not too difficult code to python for speed and power, as far as many great R libraries go, I have not the time to reinvent the wheel within python, it is not a labour of love for me.
What do I do when I get the following error message in Eclipse when trying to launch R?
"no session of R is active in the current workbench window"
I've made a tutorial for installing StatET on my Win64 system, you can find it here (mirror). Although it's no rocket science it's easy to get into issues along the way.
You need to first configure R for your system and then you also need to go into Run > Run Configurations... and add a R Console before you can run it.
You also need to be careful about the Java version that you use. I had to uninstall all my Java, then reinstall the 64-bit before it worked. I guess I could've used the 32-bit, but since I use 64-bit R I thought that it might be a better option (although I think the Eclipse environment and R don't really care about sharing bits)
for me had to select rterm, that displayed the r console/terminal. Then do run , run as -> run in R as script via source
I had the sampe problem.
go to Run > Run Configurations > RStudio
and klick on "Run"