library(dplyr) library(ggplot2)
sp_raw <- read.csv(here::here("analysis", "species_data", "species_list_working.csv"), stringsAsFactors = F, strip.white = T, na.strings = "")
Black line of fit is parameters as estimated from a lm fit to this data; blue line is using the parameters from Thibault (2011).
sp_for_sd <- filter(sp_raw, !is.na(sd)) %>% mutate(mass = as.numeric(mass), sd = as.numeric(sd)) %>% mutate(var = sd^2) %>% mutate(log_m = log(mass), log_var = log(var)) sd_fit <- lm(sp_for_sd, formula = log_var ~ log_m) summary(sd_fit) sp_for_sd <- mutate(sp_for_sd, log_var_est = -5.273 + (log_m * 1.995)) %>% mutate(var_est = exp(log_var_est), t_var_est = .0055 * (mass ^ 1.98)) %>% mutate(log_t_var_est = log(t_var_est)) ggplot(sp_for_sd, aes(x = log_m, y = log_var)) + geom_point(alpha = .4) + theme_bw() + geom_line(aes(x = log_m, y = log_var_est)) + geom_line(aes(x = log_m, y = log_t_var_est), color = "blue") ggplot(sp_for_sd, aes(x = mass, y = var)) + geom_point(alpha = .4) + theme_bw() + geom_line(aes(x = mass, y = var_est)) + geom_line(aes(x = mass, y = t_var_est), color = "blue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.