knitr::opts_chunk$set(echo = TRUE)
#Part 1
library(readr)
bird_layer <- read_csv("species richness csv files/bird layer.csv")
## Rows: 63890 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Eco_Sect, Eco_Name, County
## dbl (7): OBJECTID, Hex_ID, NtvBird, BirdEcoNorm, BirdSWNorm, Shape_Length, S...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
length(unique(bird_layer$Hex_ID))
## [1] 63890
library(readr)
mammal_layer <- read_csv("species richness csv files/mammal layer.csv")
## Rows: 63890 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Eco_Sect, Eco_Name, County
## dbl (7): OBJECTID, Hex_ID, NtvMamm, MammEcoNorm, MammSWNorm, Shape_Length, S...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
length(unique(mammal_layer$Hex_ID))
## [1] 63890
library(readr)
reptile_layer <- read_csv("species richness csv files/reptile layer.csv")
## Rows: 63890 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Eco_Sect, Eco_Name, County
## dbl (7): OBJECTID, Hex_ID, NtvRept, ReptEcoNorm, ReptSWNorm, Shape_Length, S...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
length(unique(reptile_layer$Hex_ID))
## [1] 63890
#merging dataframes
b_m_merged <- merge(bird_layer, mammal_layer, by.x = "Hex_ID", by.y = "Hex_ID", all = TRUE)
b_m_r_merged <- merge(b_m_merged, reptile_layer, by.x = "Hex_ID", by.y = "Hex_ID", all = TRUE)
## distribution
par(mfrow=c(1,3))##1 row, 3 columns
hist(b_m_r_merged$NtvRept, xlab="Reptiles", las=1, main="Distribution of Reptiles", cex.main=0.7, col="green")
hist(b_m_r_merged$NtvBird, xlab="Birds", las=1, main="Distribution of Birds", cex.main=0.7, col="lightblue")
hist(b_m_r_merged$NtvMamm, xlab="Mammals", las=1, main="Distribution of Mammals", cex.main=0.7, col="orange")
Caption for Distribution Plots: These plots show the distribution of the biodiversity of reptile, mammal, and bird species.Generally birds show a higher species richness range compared to reptiles and mammals. a) The first plot shows the distribution of reptile species in California. The biodiversity of reptiles in California per hexagonal area is between 0 and 50 species of reptiles. Most hexagonal areas have between 15 and 20 reptile species. However, there are a few hexagonal areas that have somewhere between 30 and 50 reptile species. b) The second plot shows the distribution of bird species in California. The species richness of birds in California in a hexagonal are is between 0 and 250. Most areas have between 125 and 140 bird species, but some areas have over 150 different bird species. Very few (less than 10) areas have no bird species. c) The third plot shows the distribution of mammal species in California. The species richness of mammals in California is between 0 and 85. Most hexagonal areas have between 30 and 35 bird species. There are a few areas that have less than 25 mammal species. Additionally, there are few with more than 70 mammal species.
a <- hist(b_m_r_merged$NtvRept, xlab="Reptiles", las=1, main="Distribution of Reptiles", cex.main=0.7, col="green")
b <- hist(b_m_r_merged$NtvBird, xlab="Birds", las=1, main="Distribution of Birds", cex.main=0.7, col="lightblue")
c <- hist(b_m_r_merged$NtvMamm, xlab="Mammals", las=1, main="Distribution of Mammals", cex.main=0.7, col="orange")
#pairwise plots
par(mfrow=c(1,3))##1 row, 3 columns
plot(c, col = "orange", main = "Distribution of Mammals vs Birds", xlab = "Mammals and Birds", xlim = c(0,250), ylim = c(0,17000)) # Plot 1st histogram using a transparent color
plot(b, col = rgb(1,0,0,0.5), add = TRUE) # Add 2nd histogram using different color
plot(b, col = "lightblue", main = "Distribution of Birds vs Reptiles", xlab = "Birds and Reptiles", ylim = c(0,17000)) # Plot 1st histogram using a transparent color
plot(a, col = rgb(1,0,0,0.5), add = TRUE) # Add 2nd histogram using different color
plot(c, col = "green", main ="Distribution of Mammals vs Reptiles", xlab = "Mammals and Reptiles", ylim = c(0,17000)) # Plot 1st histogram using a transparent color
plot(a, col = rgb(1,0,0,0.5), add = TRUE) # Add 2nd histogram using different color
#code is from: https://www.dataanalytics.org.uk/plot-two-overlapping-histograms-on-one-chart-in-r/#:~:text=Plot%20two%20histograms,-If%20you%20have&text=Using%20plot()%20will%20simply,on%20the%20same%20chart%2Faxis.
Caption for Pairwise Comparisons: These graphs show pairwise comparisons between of the species distribution between mammals and birds, birds and reptiles, and mammals and reptiles. a) Mammals and birds seem to have a large overlap in their distributions, but not over the whole range. When the bird biodiversity level is between 20 and 80 the mammal biodiversity level is likely between 25 and 65. b) Birds and reptiles seem to largely not overlap with their biodiversity levels. This could be that there are generally more birds than reptile species in most areas of California. The reptile species richness is at its highest when the bird species richness is a bit lower. c) Mammals and reptiles show some overlap in their species richness distributions. There tends to be more reptiles in areas where there are generally less mammals, but not always. There are a considerable number of areas with both high numbers of reptile and mammal species.
knitr::include_graphics("/Users/kristinhardy/Downloads/Data_Visualization_Class_ANTSTS_109/Bird_Species_Richness_California.jpeg")
Caption for California Map: This is a map of the bird species richness in California. The darker areas have less species of birds and the lighter areas have more species. The areas with the highest species of bird in the central valley, the Bay Area and the lower eastern part of the California coast and the north western part of California. The mountain ranges and the deserts in the south west part of California have the lowest density of bird species. This may be because the desert regions are not as habitable for avian species.