# Import required packages
library(tidyverse)
# Number of pupils
<- 30
my_pop
# Randomly generate two number for each pupil
<- tibble(
df Name = c(paste0("Pupil ", 1:my_pop)),
"Across the field in metres" = sample(x = seq(0, 100, 1), size = my_pop, replace = TRUE),
"Up the field in metres" = sample(x = seq(0, 100, 1), size = my_pop, replace = TRUE)
)
The ecology units in science are some of the most memorable lessons, for both staff and pupils. Children love to go out and do science in the real world: explore habitats and organisms under a microscope, suck an aphid into a pooter, sweep the school pond with a net, count the number of daisies on the field … .
Speaking of counting daisies on the field, this is where pupils have to sample an area for various reasons. The interesting question here is where do you begin? As far as the exam boards are concerned, you tell the pupils to randomly place a quadrat in the area in question. But how would a pupil pick a random place, and how random is this?
If you are on your own on a big wide field, closing your eyes, taking a few spins, and throwing the quadrat is good enough fun. When you have a class of 30 pupils, however, aimlessly throwing quadrats is not a good idea.
Supposing your school field is 100 m
Here’s how you can generate two random numbers for each pupil.
Note
Generating true random numbers is incredibly difficult. Since computers use mathematical formulae to generate their random numbers, they are not truly random, but rather pseudo-random. For this article, pseudo-random is fine.
This is perfectly easy to do in Excel, but the following isn’t. Here’s how you can plot a bird’s-eye view of the pupils’ positions:
|>
df ggplot(aes(x = `Across the field in metres`, y = `Up the field in metres`)) +
geom_point(shape = 4, stroke = 1, col = "violetred") +
::geom_text_repel(ggplot2::aes(label = Name), col = "grey70") +
ggrepelcoord_fixed() +
labs(
title = expression(paste("Sampling a 100 ", m^2, " field")),
subtitle = "Pupil positions generated using a random number generator in R."
)
Let’s suppose you collected the pupils’ results and it looks something like this:
The beauty of using R
is that you can quickly visualise this into something meaningful for the pupils. For very many pupils, tables are notoriously difficult to comprehend. In this case, there is too much data in table-form for anyone to see bigger patterns.
|>
df ggplot(aes(x = `Across the field in metres`, y = `Up the field in metres`, col = `Count of daisies`)) +
geom_point(size = 7) +
coord_fixed() +
labs(
x = "Across the field in metres", y = "Up the field in metres",
title = "Sampling results",
subtitle = "Visualising the count of daisies on the school field."
)
Using the {ggdensity} package, you can go one step further and plot a probability density map of the distribution of daisies on the school field.
I hope to write more about the {ggdensity} package in a future article. Keep watching.
Corrections
If you spot any mistakes or want to suggest changes, please let me know through the usual channels.
Citation
@online{teachr2022,
author = {teachR, wayward},
title = {R in School: The Ecologist},
date = {2022-08-19},
url = {https://thewaywardteachr.netlify.app/posts/2022-08-19-r-in-school-the-ecologist/r-in-school-the-ecologist.html},
langid = {en}
}