DAPR1 Workshops
  • 1: Exploratory Data Analysis
    • W1: Introductions
    • W2: Data & Variables
    • W3: Visualising Distributions
    • W4: Summarising Distributions I – Central Tendency
    • W5: Summarising Distributions II – Variability
  • 2: Introduction to Inference
    • W7: Z-scores & the Normal Distribution
  • 3: Common Statistical Tests
  • 4: The Move to Modelling

W1: Introductions

This week’s workshop is quite minimal. All we’re really wanting you to do is:

  1. Explore the software and start playing around.
  2. Meet some new people, make some new friends, and form a group to work with in these workshops.

From next week, you’ll be working in these groups collaboratively on the workshop questions, with one person doing the typing (the ‘driver’) and the others telling them what to type (the ‘navigators’). The role of driver will swap each week, so you’ll always get a turn at typing.

Question 1

The very first task here is to open RStudio.

R and RStudio is software that you can download and install on your computer, but for the duration of this course, we are providing you with a version on a server.

You can access the RStudio server by following the instructions on the FAQs page (see first drop down box).

We would recommend you bookmark the page so that you can easily find it again!

Question 2

The first thing to do is start using R just like a calculator.

Try doing some basic calculations by typing in the bottom left where you see the blue > and pressing enter.

Playing with these: *, /, +, -, ^ and seeing what happens - can you work out what each one does?

Tipstuck seeing a + symbol?

If we give R an incomplete request, then it will just stay waiting for it to be finished.

e.g., if we typed a query and missed a bracket, then R would just leave a + symbol to say “I’m waiting for more…”:

To get out of this we can either type the required stuff to finish the query, or, much more simply, just press the Escape key (Esc) on your keyboard and it will cancel the query and let you start it again.

Question 3

In order to save our work, we need to start writing our commands in a document. Something we can edit, save, come back to later on, and share with other people.

  1. Open an R Script (File > New File > R Script).
  2. A new window will pop up in the top left of RStudio. Write some calculations in there (put each one on a new line).
  3. You’ll notice that writing in the script doesn’t actually perform the calculations. We need to “Run” the commands we are writing, which we can do by ensuring the cursor is on the line we want to run, and then either:
    • press Ctrl+Enter (or Cmd+Enter for Mac)
      OR
    • clicking the “Run” button in the top right of the R Script.

Question 4
# starting a line with a "#" turns it into a comment
# it means that R will not try to run it  

# we can store things in R's memory using "name <- value", e.g.:
my_name <- "Umberto"
about_me <- "Italian."
fun_fact <- "I can play the piano."

# this -- paste() -- is a "function". 
# it takes some inputs, and gives us outputs
# in this case, we give it a whole load of separate sentence fragments
# and it sticks them together: 
paste("Hello, my name is", my_name, 
      "and I am", about_me,
      "Fun fact:", fun_fact)
  1. Copy-Paste the lines of code above into your R Script and edit them to provide some text about yourself (if you don’t want to share a fun fact about yourself, just share a random fun fact!)
  2. Save your script (File > Save).
  3. Close your script (there’s a little cross in the tab label at the top of the script)
  4. Re-open your script (File > Open)
  5. Celebrate!

Question 5

Finally, we’d like you to join your group on Blackboard Learn.

Groups are named based on the workshop (1, 2, 3, 4, 5) and your table number.
So if this is Workshop 3, and you are sitting at table 6, you should join group “Group 3_06”.

  1. Go to the course LEARN page
  2. click Groups on the top menu bar.
  3. click Workshops_1_2_3_4_5
  4. Join your group
  5. Now click on “Group Discussion Space” within the Quick Links folder of LEARN.
  6. Upload your script to the discussion space, to share your fun fact with your group members.
    • If you want step-by-step instructions for how to get your file from the RStudio server to post on the discussion space, then click here.