R Studio is an integrated development environment(IDE) for R. IDE is a GUI, where you can write your quotes, see the results and also see the variables that are generated during the course of programming.
- R Studio is available as both Open source and Commercial software.
- R Studio is also available as both Desktop and Server versions.
- R Studio is also available for various platforms such as Windows, Linux, and macOS.
Introduction to R studio for beginners:
Rstudio is an open-source tool that provides Ide to use R language, and enterprise-ready professional software for data science teams to develop share the work with their team.
R Studio can be downloaded from its official Website (https://rstudio.com/) and instructions for installation are available on How to Install RStudio for R programming in Windows?
After the installation process is over, the R Studio interface looks like:
- The console panel(left panel) is the place where R is waiting for you to tell it what to do, and see the results that are generated when you type in the commands.
- To the top right, you have the Environmental/History panel. It contains 2 tabs:
- Environment tab: It shows the variables that are generated during the course of programming in a workspace that is temporary.
- History tab: In this tab, you’ll see all the commands that are used till now from the start of usage of R Studio.
- To the right bottom, you have another panel, which contains multiple tabs, such as files,
plots, packages, help, and viewer.
- The Files tab shows the files and directories that are available within the default workspace of R.
- The Plots tab shows the plots that are generated during the course of programming.
- The Packages tab helps you to look at what are the packages that are already installed in the R Studio and it also gives a user interface to install new packages.
- The Help tab is the most important one where you can get help from the R Documentation on the functions that are in built-in R.
- The final and last tab is that the Viewer tab which can be used to see the local web content that’s generated using R.
Set the working directory in R Studio
R is always pointed at a directory on our computer. We can find out which directory by running the getwd() function. Note: this function has no arguments. We can set the working directory manually in two ways:
- The first way is to use the console and using the command setwd(“directorypath”).
You can use this function setwd() and give the path of the directory which you want to be the working directory for R studio, in the double codes.
- The second way is to set the working directory from the GUI.
To set the working directory from the GUI you have to click on this 3 dots button. When you click this, this will open up a file browser, which will help you to choose your working directory.
- Once you choose your working directory, you need to use this setting button in the more tab and click it and then you get a popup menu, where you need to select “Set as working directory”.
This will select the current directory, which you have chosen using this file browser as your working directory. Once you set the working directory, you are ready to program in R Studio.
Create an RStudio project
Step 1: Select the FILE option and select create option.
Step 2: Then select the New Project option.
Step 3: Then choose the path and directory name.
Finally, project are created in a specific location:
Creating your first R script
Here we are adding two numbers in R studio.
Navigating directories in R studio
- getwd(): Returns the current working directory.
- setwd(): Set the working directory.
- dir(): Return the list of the directory.
- sessionInfo(): Return the session of the windows.
- date(): Return the current date.
Share your thoughts in the comments
Please Login to comment...