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
## GOAL: | |
## re-create a figure similar to Fig. 2 in Wilson et al. (2018), | |
## Nature 554: 183-188. Available from: | |
## https://www.nature.com/articles/nature25479#s1 | |
## | |
## combines a boxplot (or violin) with the raw data, by splitting each | |
## category location in two (box on left, raw data on right) | |
## call required packages |
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
# somewhat hackish solution to: | |
# https://twitter.com/EamonCaddigan/status/646759751242620928 | |
# based mostly on copy/pasting from ggplot2 geom_violin source: | |
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r | |
library(ggplot2) | |
library(dplyr) | |
"%||%" <- function(a, b) { |
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(rvest) | |
library(httr) | |
library(tidyverse) | |
# get list of regions in the W7W association | |
# via API | |
sota_regions_w7w <- "https://api2.sota.org.uk/api/associations/w7w" | |
r <- GET(sota_regions_w7w) | |
dat <- | |
jsonlite::fromJSON(content(r, as = "text")) %>% |
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) | |
# using expression() for the text formatting: | |
ggplot(mtcars, | |
aes(disp, | |
mpg)) + | |
geom_point() + | |
# ~ for spaces, and * for no-space between (unquoted) expressions | |
ylab(expression(Anthropogenic~SO[4]^{"2-"}~(ngm^-3))) + | |
xlab(expression(italic(delta)^13*C[ap]*"‰")) + |
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
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries | |
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) | |
library(ggplot2) | |
td <- expand.grid( | |
hjust=c(0, 0.5, 1), | |
vjust=c(0, 0.5, 1), | |
angle=c(0, 45, 90), |
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
#' Bagplot | |
#' | |
#' The bag geom is useful for graphical summaries of scatterplots. It | |
#' is effective at showing the location, spread, skewness, and | |
#' outliers of a data set. | |
#' | |
#' A bagplot is a bivariate generalization of the well known boxplot. It | |
#' was proposed by Rousseeuw, Ruts, and Tukey. This geom plots bagplots that | |
#' are very similar to the one described in Rousseeuw et al. and | |
#' uses code from their bagplot functions in the aplpack pacakge. |
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(raster) | |
library(terra) | |
library(tidyterra) | |
library(ggplot2) | |
library(sf) | |
library(tidyverse) | |
library(ggrepel) | |
library(ggspatial) | |
# get all summits via the GeoJSON download |
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
##' Function readDFile | |
##' | |
##' Function readDFile | |
##' @param pathname the pathname of the directory containing the data to import | |
##' @return outData Output is a matrix of ion counts with rows as scantime and | |
##' columns as mass, and the respective values as labels | |
##' @export | |
readDFile<-function(pathname){ | |
filename<-file.path(pathname,'DATA.MS') |
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") |
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
# another method | |
# remotes::install_github("ropenscilabs/reviewer") | |
browseURL(reviewer::diff_rmd("analysis/paper/paper.qmd", | |
# this gets the sha of the previous commit | |
git2r::commits(n=2)[[2]]$sha)$raw) |
NewerOlder