How can I see R computation results in Visual Studio 2015? - r

I'm using R, Windows 10 and Visual Studio 2015 in my work. I can do calculations well in R console. But as I tried to make a Visual Studio project, I was unable to see the result. My code is the following:
print(2)
I tried to execute in interactive by pressing Ctrl+Enter but I can't see the result. So where do the result should appear?

(I'm assuming you have R Tools from here)
There ought to be an R Interactive window option under the R Tools > Windows menu:
Now the outputs of your R scripts (derived by highlighting some lines and pressing Ctrl-Enter) should go to that window:
If that doesn't work, can you make sure you have the latest version of R Tools? Version 1.0 only just came out recently...

Related

Autocompletion in Visual Studio Code: column names in R

I've been using R in Visual Studio Code and at the moment it seems fantastic to me.
However, there is a function that I do not know if there is any extension or not, which is the autocompletion of column names for dataframes.
Currently, I have
I have tried with the extension of R of VSCode and LSP server, somebody knows if it is possible that VSCode generates the following (like RStudio):

RStudio and Microsoft R-Open

I currently have R-statistics distribution working with RStudio.
I want to install also the Microsoft R-Open version, but how do I get RStudio to
reference this MRO distribution and not the 'regular' R-statistics.
I could not find any documentation on this either here on Stack Overflow or on RStudio's website.
So if I understand you correctly, you want to run RStudio against the Microsoft R Open version you have installed?
If so, in RStudio, go to Tools | Global Options and you will be presented with the Options dialog. Choose "General" on the right hand side and at the top you see "R version:". Click change and you will get the"Choose R Installation" dialog, where you now choose the MRO version, as per below:
Hope this helps.

RTVS can't see my regular R, and is telling me to use Microsoft R Client

I've installed R for Visual Studio (RTVS 1.0.30321.1407) on Microsoft Visual Studio 2015 Professional 2015 Version 14.0.25431.01 Update 3.
I already have regular R 3.4 on my machine, but the R Interactive window is telling me I need to install Microsoft R Client (which I don't want). The message I get upon opening an R project is:
When I try to use the R Interactive window, I get this error message:
Interactive Window is disconnected from R session.
Open Workspaces window and either select local R interpreter or try connecting to a remote machine.
How do I tell RTVS to use the latest version of R (which is already on my machine)?
There is a new "workspaces" pane in RTVS (I think you can open it under Windows or Layout menu under menu R Tools --> Windows --> Workspaces) that lets you connect to R installs. Add an R install but specify the path to the local R install and it will work fine. You can also use it to connect to Remote R installs.

R Code Runs Fine in RStudio but not in Visual Studio

I just ran this in RStudio and it works fine.
Gender <- c("Female","Female","Male","Male")
Restaurant <- c("Yes","No","Yes","No")
Count <- c(220, 780, 400, 600)
DiningSurvey <- data.frame(Gender, Restaurant, Count)
DiningSurvey
Then I try to run it in Visual Studio and it does nothing at all.
If I go to Test > Run > All Tests, I get this: 'There were successful build errors. Would you like to continue and run tests from the last successful build?' There is no last build and no matter what I try, this doesn't work. IF I hit any function key, including F5, F11, or whatever, this doesn't work!! How can I run R code in Visual Studio? It seems like this should be super-simple, but it is very, very, very difficult.
Thanks.
In general, R in VS works same a R in RStudio. In other words, F5 does not work since R is not a compiled language and does not have predefined entry point. For example, for debugging you set a breakpoint, then attach debugger, then source file and then call the desired function from R interactive window.
To run R in Visual Studio, you need the R Tools for Visual Studio (RTVS) plugin.
You can download this at http://microsoft.github.io/RTVS-docs/
This will turn Visual Studio into a capable client that knows how to deal with R.
Once you've installed RTVS, the easiest way to get started is to create a new R project:
\File\New\Project...\New R Project
This will create a new project with templates for R and Rmd files.
You can send code from an R file to the "R Interactive" window by pressing Ctrl+Enter.
You can see this in action by watching the video at https://youtu.be/KPS0ytrt9SA

How can I revert R Studio for Mac editor to default?

I just installed R Studio on my mac (was previously using on my virtual Windows machine). I am taking a class in which we learn to use R. The fix() function was demonstrated and when I ran it on my dataset it opened up an editor that was pretty ugly and done in X11 - that is, X11 launched automatically. The person next to me ran the same function but on her computer the pretty and I assume default R editor popped up. I have searched the internet and the options/preferences within R but cannot figure out how to both find out what the default would be if I did not have X11 installed AND change the editor in R Studio back to that program.
I can handle basic command line stuff if this is buried in a file I have to access through terminal/fancy preferences.
Has anyone run into this or have an idea of where to look? I don't want to use a text editor; just that nice-looking default program. Thanks!

Resources