Skip to content

Commit 2e64834

Browse files
committed
Add partials
1 parent fd0763c commit 2e64834

File tree

13 files changed

+848
-911
lines changed

13 files changed

+848
-911
lines changed

1-basics/tasks.qmd

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,4 @@
22
title: "The Basics - Tasks"
33
---
44

5-
We are going to start from scratch and build up some basic skills in R. Follow the steps below to get started.
6-
7-
::: {.callout-tip}
8-
Get R and your IDE (RStudio, VS Code, or Positron) running (see Prerequisites if needed) before starting.
9-
:::
10-
11-
Setting up your first(?) project:
12-
13-
1. In your IDE (RStudio example shown), go to `File` > `New Project...`.
14-
15-
- Select `New Directory`.
16-
- Select `New Project`.
17-
- Name the project `DS-intro-2025` and choose a directory to save it in (your OneDrive might be a good choice).
18-
- Click `Create Project`.
19-
20-
**Note**: The exact steps may vary slightly in VS Code or Positron, but the concept of project organization remains the same.
21-
22-
2. Navigate to the `Files` tab, and create two folders in the project directory: `data` and `scripts`.
23-
24-
Now using the console ***only***:
25-
26-
3. Type: `print("Hello, world!")` and hit Enter to see the output.
27-
4. Now try: `2 + 2` and hit Enter.
28-
5. Find what the current working directory is by typing `getwd()` and hitting Enter.
29-
6. Assign the value `10` to a variable named `my_number` using the assignment operator `<-` or `=`.
30-
7. Print the value of `my_number` to the console. Did it work?
31-
32-
Now, let's create your first R script:
33-
8. In RStudio, go to `File` > `New File` > `R Script`.
34-
35-
::: {.callout-note}
36-
R scripts allow you to write and save your code. You can run the code directly from the script, and it helps you keep your work organized.
37-
38-
Think of the script as a recipe that you can follow again and again! If you want to repeat your analysis or share it with others, having it in a script makes it easy.
39-
40-
All lines in the script that start with `#` are comments. They are not executed as code but are there to help explain what the code does.
41-
:::
42-
43-
8. Save the script in the `scripts` folder as `1-basics-intro.R`.
44-
45-
9. Type the following code in the new script:
46-
```R
47-
# This is my first R script
48-
print("Hello, world!")
49-
my_number <- 10
50-
print(my_number)
51-
```
52-
10. Run the code in the script by placing your cursor on each line and pressing `Ctrl + Enter` (or `Cmd + Enter` on Mac). Observe the output in the console.
53-
54-
11. Create a vector with 1000 random numbers between 0 and 100. For this, you can use the `runif()` function. Assign this vector to a variable named `random_numbers`. Check how to specify the minimum and maximum values in the `runif()` function by typing `?runif` in the console.
55-
12. Install the `tidyverse` package by typing `install.packages("tidyverse")` in the console. We won't use it now, we will load it in the next part.
56-
57-
**Optional:**
58-
59-
13. Calculate the mean and standard deviation of the `random_numbers` vector using the `mean()` and `sd()` functions. Print the results to the console.
60-
14. Save your script by clicking `File` > `Save` or pressing `Ctrl + S` (or `Cmd + S` on Mac).
5+
{{< include _tasks.qmd >}}

2-manipulation/tasks.qmd

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,4 @@
22
title: "Data Wrangling - Tasks"
33
---
44

5-
In this section, we will practice data wrangling using R and the `dplyr` package from the `tidyverse`. Follow the steps below to manipulate and explore a dataset.
6-
7-
1. Create a new R script in your `scripts` folder and name it `2-data-wrangling-and-visualization.R`.
8-
2. Load the `tidyverse` package by adding the following line at the top of your script:
9-
```R
10-
library(tidyverse)
11-
```
12-
3. Download the `crashes` file ([here](https://raw.githubusercontent.com/itsleeds/introds/refs/heads/main/00_data/crashes.csv)) and save it in your `data` folder.
13-
4. Read the `crashes` dataset into R using the `read_csv()` function and assign it to a variable named `crashes`:
14-
```R
15-
crashes <- read_csv("data/crashes.csv")
16-
```
17-
18-
5. Explore the dataset:
19-
- Use the `head()` function to view the first few rows of the dataset.
20-
- Use the `str()` function to understand the structure of the dataset.
21-
- Use the `summary()` function to get a summary of the dataset.
22-
6. Data Wrangling Tasks:
23-
- Create a new data.frame named `crashes_filtered` that includes only cyclists.
24-
- Create a new data.frame named `crashes_dark` that includes only crashes that occurred in dark conditions.
25-
- Create a new data.frame named `crashes_dark_cyclist` that includes only crashes that involved cyclists **and** occurred in dark conditions.
26-
- Create a summary table named `crashes_by_type` that shows the median age by casualty type.
27-
28-
5+
{{< include _tasks.qmd >}}

3-visualisation/tasks.qmd

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,4 @@
22
title: "3. Visualisation - Tasks"
33
---
44

5-
In this section, we will practice data visualization using R and the `ggplot2` package from the `tidyverse`. Follow the steps below to create various types of plots.
6-
7-
Using the same script `2-data-wrangling-and-visualization.R` from the previous section, continue with the following tasks:
8-
9-
If you have loaded the `tidyverse` package and read in the `crashes` dataset, you can proceed to the next steps. `ggplot2` is part of the `tidyverse`, so you don't need to load it separately.
10-
11-
1. **Box Plot:**
12-
- Create a box plot to visualise the distribution of ages for different casualty types in the `crashes` dataset.
13-
- Use `ggplot()` to specify the dataset and aesthetics, and `geom_boxplot()` to create the box plot.
14-
- Add appropriate labels and a title to your plot.
15-
- Save the box plot to an object named `age_boxplot`.
16-
- Display the plot by calling the object name.
17-
18-
2. **Bar Plot (Optional):**
19-
- Create a bar plot showing the count of casualties by type (pedestrian, cyclist, cat).
20-
- Add custom colours and transparency to the bars.
21-
- Add appropriate labels and a title.
22-
- Save the plot to an object named `casualty_barplot`.
23-
24-
3. **Export Your Plots:**
25-
- Save the box plot as a PNG file named `age_boxplot.png` using the `ggsave()` function.
26-
- Save the bar plot as a PNG file named `casualty_barplot.png`.
27-
- Check the documentation for `ggsave()` by typing `?ggsave` in the console.
28-
5+
{{< include _tasks.qmd >}}

4-statistics/index.qmd

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,4 @@
22
title: "Statistics - Tasks"
33
---
44

5-
In this part of the practical, we will use what we have learned so far to perform the same analysis you have already learned with other tools, but this time using R.
6-
7-
1. Download the datasets for this exercises and save them in your `data` folder:
8-
9-
- [ParkRun Performance Data.xlsx](https://raw.githubusercontent.com/itsleeds/introds/refs/heads/main/00_data/ParkRunPerformanceData.xlsx)
10-
- [Running Data.xlsx](https://raw.githubusercontent.com/itsleeds/introds/refs/heads/main/00_data/RunningData.xlsx)
11-
12-
2. Download the following scripts and try to run the code in them. Your job is to **debug these scripts** by fixing the intentional errors so they run correctly.
13-
14-
- Script 1: Excel Task ([R](https://github.com/itsleeds/introds/blob/main/4-statistics/task_excel_debug.R), [Python](https://github.com/itsleeds/introds/blob/main/4-statistics/task_excel_debug.py))
15-
- Script 2: SPSS Task ([R](https://github.com/itsleeds/introds/blob/main/4-statistics/task_2_spss_debug.R), [Python](https://github.com/itsleeds/introds/blob/main/4-statistics/task_2_spss_debug.py))
16-
17-
18-
5+
{{< include _index.qmd >}}

_ai.qmd

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
AI-powered coding assistants can significantly accelerate your data science learning journey. However, it is critical to use them safely and in compliance with University regulations.
3+
4+
## The "Traffic Light" System
5+
6+
The University of Leeds uses a [traffic light system](https://generative-ai.leeds.ac.uk/ai-and-assessments/categories-of-assessments/) to indicate how AI can be used in assessments. **Always check your specific module guidelines.**
7+
8+
- 🔴 **Red:** No AI permitted. You must do all the work yourself.
9+
- 🟠 **Amber:** AI permitted as a supportive tool (e.g., for ideation, debugging, or explaining concepts) but not for generating the final output.
10+
- 🟢 **Green:** AI is integral to the assessment and can be used freely (with appropriate acknowledgement).
11+
12+
## 1. The "Official" Route (Safe for Coursework)
13+
14+
**Microsoft 365 Copilot** (Enterprise) is the University-endorsed tool.
15+
16+
* **Why:** This version is **private**. Your data is *not* used to train the model (see [University guidance on GenAI tools](https://generative-ai.leeds.ac.uk/intro-gen-ai/generative-ai-tools/)). This is the recommended tool for university work where AI is permitted.
17+
* **Access:** Log in to [Microsoft 365](https://www.microsoft365.com) with your University credentials (`@leeds.ac.uk`).
18+
* **Usage:** Use it to draft text, summarize documents, or explain code concepts securely.
19+
20+
## 2. The "Developer" Route (For Personal Skills)
21+
22+
**GitHub Copilot** is an industry-standard AI pair programmer.
23+
24+
* **Context:** While excellent for coding, the standard/student version may not have the same data protections as the University's Enterprise tools.
25+
* **Usage:** Use this for **personal learning** and building your developer portfolio.
26+
* **Warning:** ⚠️ **Do not** paste unpublished assessment questions, sensitive research data, or participant information into these tools.
27+
28+
### Getting Access (Student Pack)
29+
30+
Students can get **free access** to the GitHub Student Developer Pack (a valuable industry perk):
31+
32+
1. Visit [GitHub Education](https://education.github.com/)
33+
2. Apply for the Student Developer Pack using your `.ac.uk` email (for verification only).
34+
3. Once verified, you can install the GitHub Copilot extension in VS Code or RStudio.
35+
36+
## Best Practices
37+
38+
::: callout-tip
39+
### Writing Good Prompts
40+
41+
- Write clear comments describing what you want to do
42+
- Use descriptive variable names
43+
- Break complex tasks into smaller steps
44+
:::
45+
46+
**DOs**
47+
48+
- Use AI to understand error messages
49+
- Ask AI to explain unfamiliar code
50+
- Use suggestions to learn new approaches
51+
- **Verify** AI-generated code before using it
52+
53+
**DON'Ts**
54+
55+
- Don't blindly copy-paste without understanding
56+
- Don't use AI to do all your work (you won't learn!)
57+
- **Don't share sensitive/personal data with AI tools**
58+
- Don't assume AI code is always correct
59+
60+
::: callout-warning
61+
## Critical Thinking Required
62+
63+
AI tools are powerful assistants, but they can make mistakes. Always review and test the code they generate!
64+
:::
65+
66+
## Resources
67+
68+
- [University of Leeds AI Guidance](https://library.leeds.ac.uk/info/1401/academic_skills/134/artificial_intelligence)
69+
- [Generative AI at Leeds](https://generative-ai.leeds.ac.uk/)
70+
- [AI Assessment Categories](https://generative-ai.leeds.ac.uk/ai-and-assessments/categories-of-assessments/)
71+
- [Microsoft 365 Copilot](https://www.microsoft365.com)
72+
- [GitHub Student Developer Pack](https://education.github.com/pack)

0 commit comments

Comments
 (0)