Last active
February 8, 2024 23:23
-
-
Save benmarwick/f81f7b442a462b178396ceb495a7bc56 to your computer and use it in GitHub Desktop.
Exploring the magnetic susceptibility data from Boomplas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) # you may need to install.packages("tidyverse") in the console | |
library(googlesheets4) # ditto | |
# change to your own UW email | |
gs4_auth("bmarwick@uw.edu") | |
# Get our google sheet of information about the location of each point | |
ms_data <- | |
read_sheet("https://docs.google.com/spreadsheets/d/1rDyfJQ6OnWJktIWMZfnLe8YRtCiW1PVrP9nKW1kERN4/edit?pli=1#gid=0") | |
# compute the mean values of our measurements, and then the LF and FD mass values | |
ms_data_computed <- | |
ms_data %>% | |
rowwise() %>% | |
mutate( | |
mean_lf = mean(c_across(starts_with("MS_LF")), na.rm = TRUE), | |
mean_hf = mean(c_across(starts_with("MS_HF")), na.rm = TRUE) | |
) %>% | |
ungroup() %>% | |
select(`Sample ID`, | |
mean_lf, | |
mean_hf, | |
MS_empty_pot_mass_g, | |
MS_pot_and_sediment_mass_g ) %>% | |
# χ = low frequency measured value x (10/sample mass) | |
mutate(lf = mean_lf * (10/(MS_pot_and_sediment_mass_g - MS_empty_pot_mass_g )), | |
hf = mean_hf * (10/(MS_pot_and_sediment_mass_g - MS_empty_pot_mass_g ))) %>% | |
# χFD % = 100 x ((χLF - χHF) / χLF) | |
mutate(fd = 100 * (lf - hf) / lf) | |
# draw a plot | |
lf_plot <- | |
ggplot(ms_data_computed) + | |
aes(`Sample ID`, | |
lf, | |
label = `Sample ID`) + | |
geom_line() + | |
geom_point() + | |
coord_flip() + | |
theme_minimal() + | |
ylab(bquote('χ m'~(m^3~kg^-1))) | |
fd_plot <- | |
ggplot(ms_data_computed) + | |
aes(`Sample ID`, | |
fd, | |
label = `Sample ID`) + | |
geom_line() + | |
geom_point() + | |
coord_flip() + | |
theme_minimal() + | |
# remove labels to fit nicely on the right side of the panel | |
theme(axis.text.y = element_blank(), | |
axis.title.y = element_blank()) + | |
ylab("χ fd %") | |
# draw the two plots together | |
library(cowplot) | |
plot_grid(lf_plot, | |
fd_plot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment