Skip to content

Commit

Permalink
Assessment 2
Browse files Browse the repository at this point in the history
  • Loading branch information
debruine committed Oct 10, 2024
1 parent fc9f008 commit cc9548f
Show file tree
Hide file tree
Showing 43 changed files with 8,927 additions and 1,793 deletions.
4 changes: 2 additions & 2 deletions 03-viz.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ date <- c(x = "continuous", x = "nominal", x = "ordinal", answer = "date")



## Building plots
## Building plots {#sec-plots}

```{r sim-survey, include = FALSE, eval = FALSE}
# code for simulating the data used in this chapter
Expand Down Expand Up @@ -700,7 +700,7 @@ specifying the argument `device`, which can take the following values:
"eps", "ps", "tex", "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".
:::

## Appropriate plots
## Appropriate plots {#sec-appropriate-plots}

Now that you know how to build up a plot by layers and customise its appearance, you're ready to learn about some more plot types. Different types of data require different types of plots, so this section is organised by data type.

Expand Down
4 changes: 2 additions & 2 deletions _freeze/03-viz/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/assessment-2/execute-results/html.json

Large diffs are not rendered by default.

191 changes: 132 additions & 59 deletions assessment-2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@

```{r, include=FALSE}
library(tidyverse)
library(gt)
```

A project demonstrating data visualisation and summary skills

## Instructions

TBA
Your task is to replicate [this html report](demos/report2_demo.html) using code, and to generate an appropriate visualisation for the final plot. The submission must contain the following:

* [ ] A reproducible *project structure* with all needed files (@sec-project-start)
* [ ] Document structure and text that replicate the report (@sec-reports)
* [ ] Plots that replicate Figures 1 and 2 (@sec-plots)
* [ ] A table that replicates Table 2 (@sec-summary-summarise)
* [ ] A plot that is appropriate to the description of Figure 3 (@sec-appropriate-plots)
* [ ] Consistent plot themes, colours and labels (@sec-themes)
* [ ] Cross-references in the text to the figures and tables (@sec-cross-references)
* [ ] References created using bibtex (@sec-bibliography)

## Hints and Tips

* The html theme used by the demo report is flatly
* The ggplot theme is `theme_bw()`
* `msleep` is a built-in dataset from ggplot2
* Make Table 1 using markdown
* You will need to use `summarise()` to create the data for Table 2; do not just type the numbers from the demo table
* Display Table 2 using `knitr::kable()`
* You shouldn't need any packages apart from tidyverse and knitr
* The colours for Figure 2 are "firebrick", "darkgreen", "darkorange", and "dodgerblue3"

## Submission

Expand All @@ -25,66 +44,120 @@ TBA

## Marking Rubric

You will receive green/amber/red lights for each of the elements below, and a generic feedback document explaining common issues.

```{r}
#| echo: false
rubric <- list(
"Research & Knowledge" = list(
"**Topic1**: Description" = list(
"A-Excellent" = "",
"B-Very Good" = "",
"C-Good" = "",
"D-Satisfactory" = "",
"E-Poor" = ""
)
),
"Evaluation" = list(
"**Topic2**: Description" = list(
"A-Excellent" = "",
"B-Very Good" = "",
"C-Good" = "",
"D-Satisfactory" = "",
"E-Poor" = ""
)
),
"Communication" = list(
"**Topic3**: Description" = list(
"A-Excellent" = "",
"B-Very Good" = "",
"C-Good" = "",
"D-Satisfactory" = "",
"E-Poor" = ""
)
)
)
```
* Green: Perfect or nearly perfect
* Amber: Needs some improvement
* Red: Incorrect or absent

```{r}
#| echo: false
colnames <- c("ILO",
"A: Excellent",
"B: Very Good",
"C: Good",
"D: Satisfactory",
"E: Poor")
cats <- rep(names(rubric), sapply(rubric, length))
reduce(rubric, c) |>
as_tibble() |>
t() |>
as_tibble(rownames = "ILO", .name_repair = "minimal") |>
`names<-`(colnames) |>
mutate(Category = cats) |>
select(Category, everything()) |>
group_by(Category) |>
gt::gt() |>
gt::fmt_markdown(columns = "ILO") |>
gt::tab_style(style = list(gt::cell_text(align = "left", v_align= "top")),
locations = cells_body()) |>
gt::tab_style(style = list(gt::cell_fill("#4D9FCF66")),
locations = cells_row_groups()) |>
gt::tab_style(style = list(gt::cell_borders("bottom", "grey")),
locations = cells_body()) |>
gt::opt_stylize(style = 6, add_row_striping = FALSE)
el <- c("Reproducible project",
"Document replicated",
"Captions/references",
"Figure 1 replicated",
"Figure 2 replicated",
"Table 2 replicated",
"Figure 3 appropriate",
"Consistent visualisations",
"Clean code organisation",
"Clear code",
"Efficient code"
)
n <- length(el)
data.frame(
Elements = el,
Green = paste0("<input type='radio' value='2' name='b", 1:n, "' />"),
Amber = paste0("<input type='radio' value='1' name='b", 1:n, "' />"),
Red = paste0("<input type='radio' value='0' name='b", 1:n, "' />")
) |>
knitr::kable(escape=FALSE)
```

Total: <span id="sum">0</span>/22

### Reproducible project

The project contains all of the necessary files and can be rendered by the marker.

### Document replicated

The non-code elements of the document are replicated, such as table of contents, text paragraphs, and Table 1.

### Captions/references

The figure and table captions are created correctly and quarto cross referencing is used for figures, tables, and bibliographic references.

### Figure 1 replicated

Figure 1 is created using code, and has all of the features of the example plot, such as label, axis or colour customisation.

### Figure 2 replicated

Figure 2 is created using code, and has all of the features of the example plot, such as label, axis or colour customisation.

### Table 2 replicated

Table 2 is created by summarising the data using code, and has all of the features of the example table, such as the same rounding.

### Figure 3 appropriate

You chose an appropriate geom (or set of geoms) for the relationship being demonstrated.

### Consistent visualisations

Figure 3 has consistent features with Figures 1 and 2, such as the same labels or same colours for the same levels (or different colours if you use colour to highlight different levels).

### Clean code organisation

Your code is organised in the quarto script cleanly and clearly, using separate code chunks to intersperse text and relevant code.

### Clear code

Your code chunks contain comments that clarify the purpose of the code, but not overly-explaining each step. The names you use for objects are clear, consistent, and concise.

For example, if the marker wants to assess the code that creates Table 2, they should be easily able to identify that object in the environment from the name, and easily able to find the code that creates it.

### Efficient code

While there are many ways to do the same things in R, some ways are more efficient than others. These avoid unnecessary code (e.g., do not load packages you do not use) and redundancy (e.g., do not load or process the data the same way in several places).

You will not be asked to do anything "tricky" in this assessment, so if you find yourself needing 20 lines of code just to customise the labels in a plot, try looking for more efficient alternatives.







<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script>
$(document).ready(function(){
// Function to calculate the sum
function calculateSum() {
let totalSum = 0;

// Loop through b1 to b11 to get the value of the selected radio button
for (let i = 1; i <= 11; i++) {

let selectedValue = $(`input[name='b${i}']:checked`).val();

// If a button is selected, add its value to the sum
if (selectedValue) {
totalSum += parseInt(selectedValue, 10);
}
}

// Update the total sum in the HTML
$('#sum').text(totalSum);
}

$('input[type=radio]').on('change', function(){
calculateSum();
});
});
</script>
Loading

0 comments on commit cc9548f

Please sign in to comment.