Last active
February 8, 2020 17:45
-
-
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"
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
# 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") |
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
<?xml version='1.0' encoding='UTF-8' ?> | |
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 810.00 506.25'> | |
<defs> | |
<style type='text/css'><![CDATA[ | |
line, polyline, path, rect, circle { | |
fill: none; | |
stroke: #000000; | |
stroke-linecap: round; | |
stroke-linejoin: round; | |
stroke-miterlimit: 10.00; | |
} | |
]]></style> | |
</defs> | |
<rect width='100%' height='100%' style='stroke: none; fill: #FFFFFF;'/> | |
<rect x='0.00' y='0.00' width='810.00' height='506.25' style='stroke-width: 1.07; stroke: #FFFFFF; fill: #FFFFFF;' /> | |
<defs> | |
<clipPath id='cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ=='> | |
<rect x='90.49' y='5.48' width='714.03' height='425.86' /> | |
</clipPath> | |
</defs> | |
<rect x='90.49' y='5.48' width='714.03' height='425.86' style='stroke-width: 1.07; stroke: none; fill: #FFFFFF;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='380.93' cy='32.05' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='289.39' cy='25.38' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='772.06' cy='292.00' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='322.67' cy='242.01' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='372.61' cy='358.65' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='222.81' cy='282.00' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='397.57' cy='292.00' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='306.03' cy='252.01' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='122.95' cy='381.98' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='147.91' cy='232.01' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='472.47' cy='238.68' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='235.29' cy='411.98' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='222.81' cy='387.98' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='247.78' cy='331.99' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='272.74' cy='346.99' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='239.45' cy='305.33' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<circle cx='303.95' cy='260.01' r='1.95pt' style='stroke-width: 0.71; fill: #000000;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<polyline points='122.95,205.56 131.16,207.06 139.38,208.51 147.60,209.92 155.81,211.28 164.03,212.57 172.25,213.81 180.46,214.98 188.68,216.08 196.90,217.09 205.11,218.02 213.33,218.86 221.55,219.59 229.76,220.21 237.98,220.71 246.20,221.09 254.41,221.32 262.63,221.41 270.85,221.34 279.06,221.11 287.28,220.70 295.50,220.12 303.71,219.36 311.93,218.41 320.15,217.28 328.36,215.96 336.58,214.45 344.80,212.77 353.01,210.92 361.23,208.90 369.45,206.71 377.66,204.38 385.88,201.91 394.10,199.30 402.31,196.57 410.53,193.73 418.75,190.78 426.96,187.74 435.18,184.60 443.40,181.38 451.61,178.08 459.83,174.72 468.05,171.29 476.26,167.80 484.48,164.26 492.70,160.67 500.91,157.04 509.13,153.36 517.35,149.64 525.56,145.89 533.78,142.11 542.00,138.29 550.21,134.45 558.43,130.58 566.65,126.69 574.86,122.78 583.08,118.84 591.30,114.89 599.51,110.91 607.73,106.93 615.95,102.92 624.16,98.90 632.38,94.87 640.60,90.82 648.81,86.76 657.03,82.69 665.25,78.61 673.46,74.52 681.68,70.42 689.90,66.32 698.11,62.20 706.33,58.07 714.55,53.94 722.76,49.80 730.98,45.66 739.20,41.50 747.41,37.35 755.63,33.18 763.85,29.01 772.06,24.84 772.06,404.81 763.85,402.78 755.63,400.77 747.41,398.75 739.20,396.75 730.98,394.75 722.76,392.75 714.55,390.77 706.33,388.79 698.11,386.82 689.90,384.85 681.68,382.90 673.46,380.95 665.25,379.01 657.03,377.08 648.81,375.17 640.60,373.26 632.38,371.37 624.16,369.49 615.95,367.62 607.73,365.77 599.51,363.93 591.30,362.11 583.08,360.31 574.86,358.52 566.65,356.76 558.43,355.02 550.21,353.31 542.00,351.62 533.78,349.96 525.56,348.32 517.35,346.72 509.13,345.16 500.91,343.64 492.70,342.15 484.48,340.72 476.26,339.33 468.05,337.99 459.83,336.72 451.61,335.50 443.40,334.36 435.18,333.29 426.96,332.31 418.75,331.42 410.53,330.62 402.31,329.93 394.10,329.35 385.88,328.90 377.66,328.58 369.45,328.40 361.23,328.37 353.01,328.50 344.80,328.80 336.58,329.27 328.36,329.92 320.15,330.75 311.93,331.77 303.71,332.98 295.50,334.36 287.28,335.94 279.06,337.68 270.85,339.60 262.63,341.69 254.41,343.93 246.20,346.31 237.98,348.84 229.76,351.49 221.55,354.27 213.33,357.15 205.11,360.14 196.90,363.22 188.68,366.39 180.46,369.64 172.25,372.96 164.03,376.35 155.81,379.80 147.60,383.31 139.38,386.87 131.16,390.48 122.95,394.13 ' style='stroke-width: 2.13; stroke: none; fill: #999999; fill-opacity: 0.40;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<polyline points='122.95,299.84 131.16,298.77 139.38,297.69 147.60,296.62 155.81,295.54 164.03,294.46 172.25,293.39 180.46,292.31 188.68,291.23 196.90,290.16 205.11,289.08 213.33,288.01 221.55,286.93 229.76,285.85 237.98,284.78 246.20,283.70 254.41,282.62 262.63,281.55 270.85,280.47 279.06,279.40 287.28,278.32 295.50,277.24 303.71,276.17 311.93,275.09 320.15,274.01 328.36,272.94 336.58,271.86 344.80,270.79 353.01,269.71 361.23,268.63 369.45,267.56 377.66,266.48 385.88,265.40 394.10,264.33 402.31,263.25 410.53,262.18 418.75,261.10 426.96,260.02 435.18,258.95 443.40,257.87 451.61,256.79 459.83,255.72 468.05,254.64 476.26,253.57 484.48,252.49 492.70,251.41 500.91,250.34 509.13,249.26 517.35,248.18 525.56,247.11 533.78,246.03 542.00,244.96 550.21,243.88 558.43,242.80 566.65,241.73 574.86,240.65 583.08,239.57 591.30,238.50 599.51,237.42 607.73,236.35 615.95,235.27 624.16,234.19 632.38,233.12 640.60,232.04 648.81,230.96 657.03,229.89 665.25,228.81 673.46,227.74 681.68,226.66 689.90,225.58 698.11,224.51 706.33,223.43 714.55,222.35 722.76,221.28 730.98,220.20 739.20,219.13 747.41,218.05 755.63,216.97 763.85,215.90 772.06,214.82 ' style='stroke-width: 2.13; stroke: #FF0000; stroke-linecap: butt;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<rect x='90.49' y='5.48' width='714.03' height='425.86' style='stroke-width: 1.07; stroke: #333333;' clip-path='url(#cpOTAuNDkwMXw4MDQuNTIxfDQzMS4zMzZ8NS40Nzk0NQ==)' /> | |
<defs> | |
<clipPath id='cpMHw4MTB8NTA2LjI1fDA='> | |
<rect x='0.00' y='0.00' width='810.00' height='506.25' /> | |
</clipPath> | |
</defs> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='64.42' y='428.77' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='21.13px' lengthAdjust='spacingAndGlyphs'>75</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='378.78' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>100</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='328.79' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>125</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='278.80' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>150</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='228.81' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>175</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='178.82' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>200</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='128.83' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>225</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='78.84' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>250</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='53.86' y='28.84' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='31.70px' lengthAdjust='spacingAndGlyphs'>275</text></g> | |
<polyline points='87.75,421.98 90.49,421.98 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,371.99 90.49,371.99 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,321.99 90.49,321.99 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,272.00 90.49,272.00 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,222.01 90.49,222.01 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,172.02 90.49,172.02 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,122.03 90.49,122.03 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,72.04 90.49,72.04 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='87.75,22.05 90.49,22.05 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='197.84,434.08 197.84,431.34 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='322.67,434.08 322.67,431.34 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='447.51,434.08 447.51,431.34 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='572.34,434.08 572.34,431.34 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<polyline points='697.17,434.08 697.17,431.34 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)' /> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='184.64' y='449.86' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='26.41px' lengthAdjust='spacingAndGlyphs'>0.5</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='309.47' y='449.86' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='26.41px' lengthAdjust='spacingAndGlyphs'>1.0</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='434.30' y='449.86' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='26.41px' lengthAdjust='spacingAndGlyphs'>1.5</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='559.13' y='449.86' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='26.41px' lengthAdjust='spacingAndGlyphs'>2.0</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='683.96' y='449.86' style='font-size: 19.20px; fill: #4D4D4D; font-family: Arial;' textLength='26.41px' lengthAdjust='spacingAndGlyphs'>2.5</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='447.51' y='472.32' style='font-size: 24.00px; font-family: Arial;' textLength='0.00px' lengthAdjust='spacingAndGlyphs'></text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text x='242.07' y='498.24' style='font-size: 24.00px; font-family: Arial;' textLength='410.87px' lengthAdjust='spacingAndGlyphs'>Average Chloride Concentration (ppm)</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text transform='translate(22.67,395.81) rotate(-90)' style='font-size: 24.00px; font-family: Arial;' textLength='354.81px' lengthAdjust='spacingAndGlyphs'>Average Mass of Egg Masses (g)</text></g> | |
<g clip-path='url(#cpMHw4MTB8NTA2LjI1fDA=)'><text transform='translate(48.59,218.41) rotate(-90)' style='font-size: 24.00px; font-family: Arial;' textLength='0.00px' lengthAdjust='spacingAndGlyphs'></text></g> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment