Installing RStudio and Getting Packages

R is a programming language and software environment for statistical analysis, graphics representation and reporting. It is a free tool with a large community and leverages the analysis of data via its huge package libraries that support various analysis operations.

RStudio: RStudio is a development environment for R. Its a place that is built to make using R as effective and efficient as possible. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management.

Installing RStudio:

Step 1: Visit www.rstudio.com and go to Download RStudio.

 

r1

Step 2: Click on RStudio Desktop.

 

r2

Step 3: Select Download RStudio Desktop.

 

r3

Step 4: From there you can download one to install in your system.

 

r4

Step 5: When you open RStudio after installing it in your computer, it looks like the following.

  • It has a Console where you can run any command, a Source editor where you can type in commands and scripts then save it for later.
  • An Environment which tells you about the things that you have already created, a History which keeps track of the commands that you have done and enables you to reuse them.
  • It has Packages which are bundles of functions that gives you controls to perform various tasks in R, Plots that help you analyze data graphically.
  • It also has a Help which is built in, that lets you learn about a function and what it does.

 

r6

 

Packages in R: Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages.

 

Installing Packages:

Step 1: From the toolbar of RStudio, click on Tools then Install Packages.

r7

Step 2: Now the Install Packages dialog box appears, where you can search for the package you want to install and change the location of where it will be stored.

r8

Step 3: Suppose you want to install the xlsx package, type in xlsx under the Packages area and press Install.

r9

Step 4: In the Console window, you can see the xlsx package being successfully installed.

r10

Step 5: The commands and functions built into the package are only available to you if you load the library of commands for that package.

For instance you can load the library of xlsx package. After loading you can see the required packages are also being checked under Packages. Libraries disappear when ending an R session so you must load the library each R session that you would like to use the package.

r11

Step 6: To check the previously installed Libraries/Packages type the command library().

r12

Step 7: To access the help menu for a particular package, you can type help and specify the package you would like to have help for.

r13

Step 8: To delete or remove a package, type in remove.packages and specify the package that has already been installed.

r14

Step 9: To save the R script, go to File then click on Save All or Save As and select the desired location for it to be saved.

r15

Step 10: To quit an R session, type in q() at the R prompt.

Leave A Reply

Your email address will not be published. Required fields are marked *