logo #Intro day R prep tasks

Install R & R Studio

If you have not already, then please download and install R and R Studio onto your machines. You should be using your own laptops for this course, because that way you get used to working in an environment which you will continue to use after this Masters. However, sessions will be held in computer clusters in case you do not have access to a laptop (or something goes wrong…).

Open up R Studio

When you open R studio, you see there are 4 windows

The r script and data view

This window is where you write your code and where you can view your data

R Script and Data View

For example, to create a dataframe with two columns, one called “a” and one called “b”, copy and paste the following code into an R script in your R Script and Data View window. (At this point dont worry about syntax etc)

myDf <- data.frame(a = c(1, 2, 3, 4, 5), b = c(5, 4, 3, 2, 1))

Then highlight this bit of code you just copy and pasted with your mouse, and click on “Run” on the top right hand corner of the r script and data view window.

You’ve just run your first bit of r code, which was to create this dataframe. Now if you want to view this, that also happens in the r script and data view window. To do this, copy paste and run the code below like you did with the previous.

View(myDf)

Now a window will appear showing you the dataframe which you created earlier. To toggle between windows here, use the tabs.

Console view

Below the r script and data view there is the console view.