Tags

Installing R and Rstudio

Here are step by step instructions for installing R and Rstudio. R is a useful and free application for data analytics that is widely used by statisticians and data miners. RStudio provides a more user friendly interface that will speed up your learning greatly!

Macs
Download and install R “3.0.3 pkg” here: Mac Install

Windows
Download and install R here: Windows Install

Linux
Download and install R here: Linux Install

Next, choose the appropriate package for RStudio here: RStudio Install

Setting Your Working Directory

Your working directory is the folder which you are directing R to extract and save files. First create a folder called “Leada” on your desktop.

Now in RStudio, we must create a file for us to write in. Go to File ==> New ==> Rscript. In this Rscript we must tell R where our current working directory is. We do this by using the setwd() function. Your working directory indicates to R which folder to look for the datasets you want to use. Remember everything in R you type is case sensitive!

For Mac Users:

getwd()

setwd("/Users/your_user_name/Desktop/Leada/")

If your confused you can use the image below as an example, the correct code would be:

setwd("/Users/Clair/Desktop/Leada/")

Path Image
For Windows users:

getwd()

setwd("C:/Users/your_user_name/Desktop/Leada")

Running you RCode

To run what you just wrote in your RScript, put your cursor on a line of code in your RScript and enter control and return at the same time! It should now pop up on the bottom left window labeled Console in blue, and if there is no red code that follows it has run correctly. Congrats you’ve just run your first line of R code! From now on you can run any of our code snippets by copy and pasting it into your own RScript, and entering control and return. Typingcontrol and return on any part of the line runs the entire line of RCode.

Happy Learning!

Advertisements