Introduction and Background
Previously we talked a lot about installing and setting up the environment for R language. In this post, I will walk you through different stuff that Visual Studio provides you with. Typically, every R IDE supports the following tools and features for data processing.
- A scripting toolkit; where you can write R language code.
- An R interactive shell for executing the commands.
- Plot builder for plotting the graphics.
- Markdown editors and much more.
I will walk you through these windows in Visual Studio IDE itself and will give examples of using Visual Studio as your default IDE for R programming. In my personal (and humble) opinion, I think Visual Studio is the best IDE out there, provided its simplicity, ease of use, and now that the price has also dropped down to zero for personal use! What more can someone ask for?
Exploring Visual Studio for R
I have talked about the things that we are going to explore in this post. Those are listed above, and in this section I am going to expand them and I am going to demonstrate what benefit they have for R developers in the industry of data science.

Figure 1: Visual Studio logo
Besides R, Visual Studio is also going to have the tools for Java programming. At least, I am very much excited about Visual Studio’s future, in which it is going to be used as a universal IDE. But in this post we should just focus on the R tools provided. If you have not yet set up the R tools for Visual Studio, I recommend that you read the post of mine for that, Installing and setting up R environment on Windows. This would help you to set up the environment for data analysis using R language.
1. R code editor
First thing to know about in any IDE for any programming language, is the code editor that it has. Code editors are simply the text editors, but there are a few other additional features that it has apart from the ordinary text editing and caching services. Visual Studio code editor provides the following powerful features:
- R syntax highlighting
• Every IDE should support syntax highlighting and highlight the different data types, different keywords and the scope resolutions like matching brackets.
- Autocomplete suggestions.
• Visual Studio calls them IntelliSense, which provides the easy way of writing the programs. It provides the clean way of providing suggestions for function calls and the parameter lists.
- Squiggly lines for errors
• It is better to show off the errors in the language syntax or commands, before programmers build their project and finally stumble upon the errors. Visual Studio shows the errors if there are any, in the commands using the interpreters!

Figure 2: Visual Studio code editor
This is the most basic usage of the code editor at now. Visual Studio renders the codes in their own format, R syntax has been implemented in Visual Studio to support for string literals, keywords, comments and matching brackets.
You should consider using the R code editor instead of using a plain-text file to write the R scripts.
2. R interactive shell
Every interpreted programming language has an interactive shell. Python has it, so does R because R is an interpreted language. Interactive shells allow you to execute minimal programs, commands, and test the environment itself. They are also used to compile (interpret!) and execute the statements in the source file that you may have somewhere.
Visual Studio supports the Interactive Shell. If you do not find it, it is right there under R Tools → Windows → R Interactive. The Window allows you to enter the commands to:
- Create new variables in the environment.
- Explore the environment.
- Print the variables.
- Perform calculations on the data.

Figure 3: R interactive shell
You can see that the R project starts, and then it allows the users to enter the commands that are to be tested or executed in the R environment. If you pay a bit more attention, you will see that i am currently running Microsoft’s R Open,

Figure 4: Microsoft R Open being used in the shell
This allows you to add the commands which require execution. You can perform many functions in this shell as already mentioned above.

Figure 5: Executing commands in R Interactive Shell
You can also run other versions of the R. But, Microsoft R Open is the Microsoft’s implementation and distribution of R language. To change the currently active engine to be used for R, you need to have other versions of R installed on your machine. If they are available, then you can update the current active R engine from the settings themselves. Just select R Tools → Options. Inside those options, select the path for the R engine’s installation folder.

Figure 6: Options in R Tools
Select this field and update the directory which it targets to target another directory for a different R engine. Once done, you can restart the Visual Studio to take the actions.
3. Plotting graphs
Another great feature of R programming is that it provides you with native support for graphical presentations. If you want to build charts, pie charts and bar charts or graphs. You can get the functions that can do the trick for you! In no time, you will be up and running your own projects, presentations and anything.
Benefit is that R generates quality and enterprise ready graphics, not just careless graphics! You can show the R plot window by either executing the command for plotting the graph or by manually opening it. To select the R plot, you can go to R Tools → Windows → R Plot. You can then direct R to build and generate the graphics on the plotter, a few of the commands used are:





Hadshana KamalanathanPosted Jul 22, 2018, 4:00 AM
Useful one, Thanks for sharing
Jaipal ReddyPosted Mar 24, 2016, 12:01 AM
Nice One. .
Mahesh ChandPosted Mar 23, 2016, 9:42 PM
Every new article you write, your quality and writing improves. I am impressed, Afzaal. It's a shame, you were unable to come to the conference. May be one day.
Kumaresh RajalingamPosted Mar 23, 2016, 9:12 PM
Nice one
Debasis SahaPosted Mar 23, 2016, 1:26 PM
Nice one..
Vignesh ManiPosted Mar 22, 2016, 9:12 AM
good
Jaipal ReddyPosted Mar 22, 2016, 4:55 AM
Nice share. .
Sibeesh VenuPosted Mar 22, 2016, 4:50 AM
Nice share mate, I guess I will have to give a try in R language now :)
Mohammed IbrahimPosted Mar 22, 2016, 4:26 AM
nice