This lab builds directly on what you covered in Homework 1 on DataCamp. The goal is to get comfortable using R and R-Markdown, and to learn how some of the key pieces fit together. In Lab 2, we will explore similar ideas but with spatial data
In this lab, you will learn how to
You are allowed to use your own laptops, Posit-Cloud or the lab computers (very slow) to complete this lab.
This is a one-week lab. You’ll likely finish most of it
during your lab session, with about 4 additional hours of work at home.
So you can expect it to take around 6 hours total.
If it’s taking much longer than that, please reach
out! Don’t struggle in silence.
Submission instructions and a checklist-style grading rubric are included at the end of this lab.
Your deadline depends on which lab section you’re in::
IIf something comes up and you’re running late, don’t panic — click this link for the late policy.
Please read the the lab FAQ for guidance on using tools like ChatGPT and answers to common questions. We will also be talking about ChatGPT in the next week or so.
If you get stuck, here’s how to find help:
DURING LABS
DURING OFFICE HOURS
PIAZZA DISCUSSION BOARD
LAST RESORT (IF NO REPLY ON PIAZZA)
IF YOU HAVEN’T COMPLETED HOMEWORK 1, GO AND DO IT
NOW!
This lab builds on Homework 1, so it’s important
you complete it first. Click
here to go to the homework.
I have extended the
deadline just this once because it’s an important starting point for
your labs.
An R Project is like a home base for all the files, scripts, and data connected to one piece of work. Instead of saving files in lots of different places and then struggling to tell R where to look, the Project keeps everything together. Here’s why projects are so useful:
Consistency across computers: If you move from Posit Cloud to a lab computer or your own laptop, you only need to copy the Project folder. Open it, and everything inside will still “know where it lives.”
No messy file paths: You won’t have to keep typing or updating long folder names. R will automatically treat your Project folder as the starting point.
Everything is organised: Each lab, assignment, or project has its own container, so your work never gets tangled.
Easy to share or back up: You can zip up the folder, send it, or store it in GitHub/OneDrive, and it will still work when reopened.
Watch this video to find out more:
Before you start using RStudio, it helps to adjust a few settings to make your lives easier.
Just like the factory settings on your phone are pretty boring, in R we often want to download/install apps to do specific commands. In R, we call apps packages or libraries.
To download new packages
Go to the Packages Tab. The list you see are the ones currently installed on your computer (like the calculator is pre-installed on your phone).
Now, Click the INSTALL button. This takes you to the app store where you can type the name of a package you want to download.
tidyverse - plotly -
palmerpenguins - ggstatsplot -
readxlJust like you don’t need to go to the App store every time you want to open instagram, you only need to do this ONCE for each package. (on posit cloud it might happen more often). The install commands should never be in your lab report.
If you need more help, see here Tutorial: Packages)
You are going to write up your labs as R-Markdown files (ones ending in .Rmd). These can include both code and text - and they are easy to turn into websites, pdf documents, presentations and many other things.
YOU SHOULD BE RUNNING YOUR PROJECT AT THIS POINT. MAKE SURE IT SAYS LAB-1 AT THE TOP OF YOUR SCREEN.
IF YOU ARE ON POSIT-CLOUD, first download it to your computer/desktop. THEN follow these instructions to upload it into your Lab 1 workspace: https://docs.posit.co/cloud/guide/data/
Rename the file
“GEOG364_Lab1_AddYourEmailID.Rmd” should now be in your Lab 1 project
folder (either on your computer or on posit-cloud).
In
R-Studio, look at the Files Tab to the next to Projects/Help in one
quadrant. If you are running your Lab 1 you should be able to see it.
Click the tick-box next to it and click the Rename button. Change
AddYourEmailID to your PSU email ID e.g. mine is hlg5155.
Open the file & follow the instructions!. Come back here at the end.
Reminder: An A is 94%. You can skip this section and still earn an A.
At the very end of your lab script there is a section called “Show me something new.” This is a space for you to explore and show off something beyond the required questions.
2/4 points for any genuine attempt at something new.
4/4 points if what you try is especially creative or well explained in your own words
Important: You must explain in your own words what you did and why, not just paste in code or screenshots.
The idea is simple: R and RStudio can do much more than what fits in a single lab. If you find the lab easy, this gives you a way to stretch yourself (100% is hard to get!). Equally, if you struggled with an earlier section, this is a chance to earn back some points.
So this section is a chance for you to:
Please don’t just copy/paste ChatGPT code. The whole point of this is to stretch your knowledge of R in a low-stakes way. You can use it in the same way you would talk to a friend e.g. to bounce ideas off or help you fix something that isn’t working. But know that I will value something smaller that’s clearly yours and explained in your own words, over something very fancy that you copy/pasted from AI.
Remember to save your work throughout and to spell check! (next to the save button). Now, press the knit button one final time.
You will be submitting TWO FILES. Your RmD file and the html website you made. Keep reading for how to find them.

Press knit. If you have not made any mistakes in the code then R should create a html file in your lab 1 folder which includes your answers.
Look at the Files tab (next to Projects/Help in one quadrant). You will see a list of files: one with the file type .Rmd (your code) and one with .html (the website you made when you pressed knit). Look at the red circle in the pic below.

Overall, here is what your lab should correspond to:
| Grade | % Mark | Rubric |
|---|---|---|
| A* | 98-100 | Exceptional. Not only was it near perfect, but the graders learned something. THIS IS HARD TO GET. |
| NA | 96+ | You went above and beyond |
| A | 93+: | Everything asked for with high quality. Class example |
| A- | 90+ | The odd minor mistake, All code done but not written up in full sentences etc. A little less care |
| B+ | 87+ | More minor mistakes. Things like missing units, getting the odd question wrong, no workings shown |
| B | 83+ | Solid work but the odd larger mistake or missing answer. Completely misinterpreted something, that type of thing |
| B- | 80+ | Starting to miss entire/questions sections, or multiple larger mistakes. Still a solid attempt. |
| C+ | 77+ | You made a good effort and did some things well, but there were a lot of problems. (e.g. you wrote up the text well, but messed up the code) |
| C | 70+ | It’s clear you tried and learned something. Just attending labs will get you this much as we can help you get to this stage |
| D | 60+ | You attempt the lab and submit something. Not clear you put in much effort or you had real issues |
| F | 0+ | Didn’t submit, or incredibly limited attempt. |
And.. finished!