Skip to content

Instantly share code, notes, and snippets.

@sumanthratna
Last active February 8, 2020 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumanthratna/2a379a616f773a5e8c714357bc71ad7a to your computer and use it in GitHub Desktop.
Save sumanthratna/2a379a616f773a5e8c714357bc71ad7a to your computer and use it in GitHub Desktop.
Code to generate graphs for our IBET paper, "Road Salt: at Fault? The Effect of Chloride Concentration on the Mass of Ambystoma maculatum Egg Masses"
# ourdata is data we collected (from the 2018-2019 school year)
ourdata <-
data.frame(
chloride = c(
1.233333333,
0.866666667,
2.8,
1,
1.2,
0.6,
1.3,
0.933333333,
0.2,
0.3,
1.6,
0.65,
0.6,
0.7,
0.8,
0.6666666667,
0.925
),
mass = c(
270,
273.3333333,
140,
165,
106.667,
145,
140,
160,
95,
170,
166.6666667,
80,
92,
120,
112.5,
133.3333333,
156
)
)
# hisdata is the historical data (from the 2017-2018 school year)
hisdata <-
data.frame(
chloride = c(
1.8,
3.2,
2.2,
2.2,
5.8,
1.7,
1.9,
2.4,
3.4,
2.8,
2.95,
2.7,
5.1,
5.24,
5.6,
4.9,
6.1,
6.7
),
mass = c(
105,
100,
115,
110,
95,
165,
135,
120,
80,
90,
85,
86,
65,
70,
75,
90,
85,
40
)
)
par(family = "Times New Roman")
plot(lm(ourdata), which = 1)
abline(0, 0)
hist(
resid(lm(ourdata)),
col = "gray",
main = "Histogram of Residuals",
xlab = "Residual",
ylab = "Frequency"
)
library(ggplot2)
# ggplot(ourdata, aes(x = ourdata$chloride, ourdata$mass)) + geom_point(aes(x = chloride, y = mass), stat = "identity") + theme_classic() + theme(axis.title.x = element_text(size = 32, family = "Pontano Sans"), axis.title.y = element_text(size = 32, family = "Pontano Sans"), axis.title = element_text(size = 18, family = "Pontano Sans"), plot.caption = element_text(hjust = 0, family = "Pontano Sans"), axis.text = element_text(size = 24, family = "Pontano Sans")) + xlab("Average Chloride Concentration (ppm)") + ylab("Average Mass of Egg Masses (g)\n") + scale_y_continuous(breaks = seq(0, 300, by = 25)) + scale_x_continuous(breaks = seq(0, 21, by = 0.5)) + stat_smooth(method = "lm", col = "red")
ourscat <-
ggplot(ourdata, aes(x = ourdata$chloride, ourdata$mass)) + geom_point(aes(x = chloride, y = mass), stat = "identity") + theme_classic() + theme(
axis.title.x = element_text(size = 32, family = "Calibri"),
axis.title.y = element_text(size = 32, family = "Calibri"),
axis.title = element_text(size = 18, family = "Calibri"),
plot.caption = element_text(hjust = 0, family = "Calibri"),
axis.text = element_text(size = 24, family = "Calibri")
) + xlab("Average Chloride Concentration (ppm)") + ylab("Average Mass of Egg Masses (g)\n") + scale_y_continuous(breaks = seq(0, 300, by = 25)) + scale_x_continuous(breaks = seq(0, 21, by = 0.5)) + stat_smooth(method = "lm", col = "red")
ourscat
library(officer)
library(rvg)
library(tidyverse)
read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with_vg(code = print(ourscat), type = "body") %>%
print(target = "/tmp/ourscat.pptx")
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment