Let’s explore my first R Markdown file together. I am following a tutorial from Coding Club, linked here: https://ourcodingclub.github.io/tutorials/rmarkdown/. Coding Club provided a practice script in RStudio. I am taking that script and using it to make this page. Pretty neat!
This is a preliminary investigation into the biodiversity of Edinburgh, using data from the National Biodiversity Network Gateway https://data.nbn.org.uk/.
A table of species richness:
richness <-
edidiv %>%
group_by(taxonGroup) %>%
summarise(Species_richness = n_distinct(taxonName))
pander(richness)| taxonGroup | Species_richness |
|---|---|
| Beetle | 37 |
| Bird | 86 |
| Butterfly | 25 |
| Dragonfly | 11 |
| Flowering.Plants | 521 |
| Fungus | 219 |
| Hymenopteran | 112 |
| Lichen | 94 |
| Liverwort | 40 |
| Mammal | 33 |
| Mollusc | 97 |
A barplot of the table above:
barplot(richness$Species_richness,
names.arg = richness$taxonGroup,
xlab="Taxa", ylab="Number of species",
ylim=c(0,600)
) A table of the most common species:
#Create a vector of most abundant species per taxa
max_abund <-
edidiv %>%
group_by(taxonGroup) %>%
summarise(taxonName = names(which.max(table(taxonName))))
#Add the vector to the data frame
richness_abund <-
inner_join(richness, max_abund, by = "taxonGroup")
richness_abund <- rename(richness_abund, Most_abundant = taxonName, Taxon = taxonGroup)richness_abund <- rename(richness_abund,
"Most Abundant" = Most_abundant,
"Species Richness" = Species_richness) #Change the column names
emphasize.italics.cols(3) #Make the 3rd column italics
pander(richness_abund) #Create a table| Taxon | Species Richness | Most Abundant |
|---|---|---|
| Beetle | 37 | Coccinella septempunctata |
| Bird | 86 | Turdus merula |
| Butterfly | 25 | Maniola jurtina |
| Dragonfly | 11 | Ischnura elegans |
| Flowering.Plants | 521 | Urtica dioica |
| Fungus | 219 | Auricularia auricula-judae |
| Hymenopteran | 112 | Bombus (Bombus) terrestris |
| Lichen | 94 | Xanthoria parietina |
| Liverwort | 40 | Lophocolea bidentata |
| Mammal | 33 | Sciurus carolinensis |
| Mollusc | 97 | Cornu aspersum |