11 5 2014 Degree Days to Peak Brood with Graph

Updated Degree Day graph to show degree days after peak spawn of last group.

tempandspawning.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(plyr)
## Loading required package: plyr
require(doBy)
## Loading required package: doBy
## Loading required package: survival
## Loading required package: splines
## Loading required package: MASS
require(ggplot2)
## Loading required package: ggplot2
reproanalysis<-read.csv('ReproAnalysis.csv', header=T)
print(reproanalysis)
##       X       Date       Site Temp Pop Brooders Gaping Percent Dead Closed
## 1 1 2014-05-02 Fidalgo 10.0 N 0 0 0.000 NA NA
## 2 2 2014-05-16 Fidalgo 9.0 N 0 53 0.000 0 46
## 3 3 2014-05-24 Fidalgo 10.0 N 0 24 0.000 0 86
## 4 4 2014-05-30 Fidalgo 10.0 N 0 46 0.000 0 50
## 5 5 2014-06-06 Fidalgo 10.0 N 1 59 1.695 2 36
## 6 6 2014-06-13 Fidalgo 7.0 N 0 68 0.000 1 27
## 7 7 2014-06-20 Fidalgo 8.0 N 0 76 0.000 0 34
## 8 8 2014-06-27 Fidalgo 9.0 N 1 87 1.149 0 6
## 9 9 2014-07-04 Fidalgo 9.0 N 1 82 1.220 0 13
## 10 10 2014-07-11 Fidalgo 16.0 N 0 78 0.000 0 17
## 11 11 2014-07-18 Fidalgo 10.0 N 0 68 0.000 0 40
## 12 12 2014-07-25 Fidalgo 11.0 N 0 55 0.000 0 45
## 13 13 2014-08-01 Fidalgo 10.0 N 0 28 0.000 0 68
## 14 14 2014-08-08 Fidalgo 11.0 N 5 89 5.618 0 10
## 15 15 2014-04-30 Manchester 9.5 N 0 0 0.000 NA NA
## 16 16 2014-05-14 Manchester 9.0 N 0 31 0.000 0 28
## 17 17 2014-05-21 Manchester 10.0 N 0 40 0.000 3 48
## 18 18 2014-05-28 Manchester 13.0 N 0 54 0.000 15 28
## 19 19 2014-06-04 Manchester 8.0 N 0 43 0.000 15 32
## 20 20 2014-06-11 Manchester 9.0 N 0 41 0.000 8 12
## 21 21 2014-06-18 Manchester 7.0 N 0 73 0.000 2 12
## 22 22 2014-06-25 Manchester 10.0 N 1 53 1.887 23 19
## 23 23 2014-07-02 Manchester 10.0 N 0 40 0.000 20 18
## 24 24 2014-07-09 Manchester 11.0 N 0 45 0.000 12 2
## 25 25 2014-07-16 Manchester 10.0 N 0 61 0.000 6 8
## 26 26 2014-07-23 Manchester 8.0 N 0 60 0.000 10 9
## 27 27 2014-07-30 Manchester 11.0 N 0 45 0.000 12 7
## 28 28 2014-08-06 Manchester 18.0 N 0 45 0.000 4 5
## 29 29 2014-05-01 Oyster Bay 11.0 N 0 NA 0.000 NA NA
## 30 30 2014-05-15 Oyster Bay 13.0 N 0 46 0.000 7 14
## 31 31 2014-05-22 Oyster Bay 13.0 N 0 3 0.000 93 5
## 32 32 2014-05-29 Oyster Bay 15.0 N 2 51 3.922 6 10
## 33 33 2014-06-05 Oyster Bay 13.0 N 1 52 1.923 7 8
## 34 34 2014-06-12 Oyster Bay 15.0 N 2 48 4.167 8 1
## 35 35 2014-06-19 Oyster Bay 16.0 N 3 54 5.556 8 1
## 36 36 2014-06-26 Oyster Bay 14.0 N 7 156 4.487 26 2
## 37 37 2014-07-03 Oyster Bay 15.0 N 0 49 0.000 0 1
## 38 38 2014-07-10 Oyster Bay 16.0 N 8 73 10.959 3 2
## 39 39 2014-07-17 Oyster Bay 16.0 N 0 48 0.000 1 1
## 40 40 2014-07-24 Oyster Bay 15.0 N 3 68 4.412 0 10
## 41 41 2014-07-31 Oyster Bay 17.0 N 1 50 2.000 0 0
## 42 42 2014-08-07 Oyster Bay 15.0 N 3 71 4.225 0 7
## 43 43 2014-05-02 Fidalgo 10.0 H 0 NA 0.000 NA NA
## 44 44 2014-05-16 Fidalgo 9.0 H 0 48 0.000 0 52
## 45 45 2014-05-24 Fidalgo 10.0 H 0 53 0.000 0 30
## 46 46 2014-05-30 Fidalgo 10.0 H 0 50 0.000 1 40
## 47 47 2014-06-06 Fidalgo 10.0 H 0 58 0.000 0 33
## 48 48 2014-06-13 Fidalgo 7.0 H 0 72 0.000 0 27
## 49 49 2014-06-20 Fidalgo 8.0 H 0 77 0.000 0 10
## 50 50 2014-06-27 Fidalgo 9.0 H 0 65 0.000 0 28
## 51 51 2014-07-04 Fidalgo 9.0 H 1 88 1.136 0 9
## 52 52 2014-07-11 Fidalgo 16.0 H 0 70 0.000 0 28
## 53 53 2014-07-18 Fidalgo 10.0 H 2 32 6.250 0 50
## 54 54 2014-07-25 Fidalgo 11.0 H 2 50 4.000 0 36
## 55 55 2014-08-01 Fidalgo 10.0 H 0 84 0.000 0 2
## 56 56 2014-08-08 Fidalgo 11.0 H 3 67 4.478 0 15
## 57 57 2014-04-30 Manchester 9.5 H 0 NA 0.000 NA NA
## 58 58 2014-05-14 Manchester 9.0 H 0 25 0.000 0 72
## 59 59 2014-05-21 Manchester 10.0 H 0 16 0.000 2 66
## 60 60 2014-05-28 Manchester 13.0 H 0 27 0.000 0 58
## 61 61 2014-06-04 Manchester 8.0 H 0 55 0.000 11 23
## 62 62 2014-06-11 Manchester 9.0 H 0 63 0.000 2 31
## 63 63 2014-06-18 Manchester 7.0 H 0 63 0.000 4 12
## 64 64 2014-06-25 Manchester 10.0 H 1 52 1.923 7 33
## 65 65 2014-07-02 Manchester 10.0 H 0 52 0.000 20 8
## 66 66 2014-07-09 Manchester 11.0 H 1 60 1.667 5 21
## 67 67 2014-07-16 Manchester 10.0 H 1 56 1.786 8 17
## 68 68 2014-07-23 Manchester 8.0 H 1 67 1.493 7 9
## 69 69 2014-07-30 Manchester 11.0 H 1 45 2.222 9 11
## 70 70 2014-08-06 Manchester 18.0 H 2 77 2.597 12 5
## 71 71 2014-05-01 Oyster Bay 11.0 H 0 NA 0.000 NA NA
## 72 72 2014-05-15 Oyster Bay 13.0 H 0 49 0.000 7 33
## 73 73 2014-05-22 Oyster Bay 13.0 H 0 47 0.000 51 9
## 74 74 2014-05-29 Oyster Bay 15.0 H 1 80 1.250 7 2
## 75 75 2014-06-05 Oyster Bay 13.0 H 2 79 2.532 7 3
## 76 76 2014-06-12 Oyster Bay 15.0 H 1 86 1.163 8 1
## 77 77 2014-06-19 Oyster Bay 16.0 H 0 70 0.000 9 7
## 78 78 2014-06-26 Oyster Bay 14.0 H 1 92 1.087 4 1
## 79 79 2014-07-03 Oyster Bay 15.0 H 3 66 4.545 4 4
## 80 80 2014-07-10 Oyster Bay 16.0 H 6 83 7.229 3 3
## 81 81 2014-07-17 Oyster Bay 16.0 H 5 68 7.353 6 1
## 82 82 2014-07-24 Oyster Bay 15.0 H 4 72 5.556 4 6
## 83 83 2014-07-31 Oyster Bay 17.0 H 1 59 1.695 2 8
## 84 84 2014-08-07 Oyster Bay 15.0 H 2 80 2.500 0 6
## 85 85 2014-05-02 Fidalgo 10.0 S 0 NA 0.000 NA NA
## 86 86 2014-05-16 Fidalgo 9.0 S 0 55 0.000 0 NA
## 87 87 2014-05-24 Fidalgo 10.0 S 0 77 0.000 0 NA
## 88 88 2014-05-30 Fidalgo 10.0 S 0 77 0.000 1 55
## 89 89 2014-06-06 Fidalgo 10.0 S 0 53 0.000 1 26
## 90 90 2014-06-13 Fidalgo 7.0 S 7 83 8.434 1 39
## 91 91 2014-06-20 Fidalgo 8.0 S 1 83 1.205 0 8
## 92 92 2014-06-27 Fidalgo 9.0 S 3 87 3.448 0 4
## 93 93 2014-07-04 Fidalgo 9.0 S 6 71 8.451 0 21
## 94 94 2014-07-11 Fidalgo 16.0 S 11 81 13.580 0 11
## 95 95 2014-07-18 Fidalgo 10.0 S 0 67 0.000 0 26
## 96 96 2014-07-25 Fidalgo 11.0 S 6 72 8.333 0 32
## 97 97 2014-08-01 Fidalgo 10.0 S 3 45 6.667 0 49
## 98 98 2014-08-08 Fidalgo 11.0 S 2 70 2.857 0 23
## 99 99 2014-04-30 Manchester 9.5 S 0 NA 0.000 NA 43
## 100 100 2014-05-14 Manchester 9.0 S 0 43 0.000 0 37
## 101 101 2014-05-21 Manchester 10.0 S 0 76 0.000 3 6
## 102 102 2014-05-28 Manchester 13.0 S 0 43 0.000 9 3
## 103 103 2014-06-04 Manchester 8.0 S 0 60 0.000 3 28
## 104 104 2014-06-11 Manchester 9.0 S 0 49 0.000 12 1
## 105 105 2014-06-18 Manchester 7.0 S 1 55 1.818 10 10
## 106 106 2014-06-25 Manchester 10.0 S 0 50 0.000 2 13
## 107 107 2014-07-02 Manchester 10.0 S 0 31 0.000 4 2
## 108 108 2014-07-09 Manchester 11.0 S 0 55 0.000 22 6
## 109 109 2014-07-16 Manchester 10.0 S 3 59 5.085 12 48
## 110 110 2014-07-23 Manchester 8.0 S 2 59 3.390 1 3
## 111 111 2014-07-30 Manchester 11.0 S 1 69 1.449 10 14
## 112 112 2014-08-06 Manchester 18.0 S 4 50 8.000 11 15
## 113 113 2014-05-01 Oyster Bay 11.0 S 0 NA 0.000 NA 1
## 114 114 2014-05-15 Oyster Bay 13.0 S 0 59 0.000 8 11
## 115 115 2014-05-22 Oyster Bay 13.0 S 0 2 0.000 68 12
## 116 116 2014-05-29 Oyster Bay 15.0 S 5 74 6.757 9 2
## 117 117 2014-06-05 Oyster Bay 13.0 S 2 60 3.333 12 30
## 118 118 2014-06-12 Oyster Bay 15.0 S 3 63 4.762 11 6
## 119 119 2014-06-19 Oyster Bay 16.0 S 11 80 13.750 12 7
## 120 120 2014-06-26 Oyster Bay 14.0 S 11 85 12.941 10 25
## 121 121 2014-07-03 Oyster Bay 15.0 S 9 78 11.538 0 10
## 122 122 2014-07-10 Oyster Bay 16.0 S 10 82 12.195 0 2
## 123 123 2014-07-17 Oyster Bay 16.0 S 0 75 0.000 1 38
## 124 124 2014-07-24 Oyster Bay 15.0 S 8 75 10.667 4 7
## 125 125 2014-07-31 Oyster Bay 17.0 S 0 70 0.000 0 1
## 126 126 2014-08-07 Oyster Bay 15.0 S 10 80 12.500 0 22
## Total Tide arcsinbrooders prop arcsinprop
## 1 100.00 -0.84 0.000 NA 0.0000
## 2 99.00 -2.27 0.000 0.00000 0.0000
## 3 110.00 1.12 0.000 0.00000 0.0000
## 4 96.00 -1.46 0.000 0.00000 0.0000
## 5 98.69 3.13 1.571 0.01695 0.1306
## 6 96.00 -2.81 0.000 0.00000 0.0000
## 7 110.00 2.14 0.000 0.00000 0.0000
## 8 94.15 -1.42 1.571 0.01149 0.1074
## 9 96.22 2.58 1.571 0.01220 0.1107
## 10 95.00 -2.57 0.000 0.00000 0.0000
## 11 108.00 2.05 0.000 0.00000 0.0000
## 12 100.00 -0.78 0.000 0.00000 0.0000
## 13 96.00 2.39 0.000 0.00000 0.0000
## 14 104.62 -1.66 0.000 0.05618 0.2393
## 15 90.00 -1.50 0.000 NA 0.0000
## 16 59.00 -1.63 0.000 0.00000 0.0000
## 17 91.00 0.87 0.000 0.00000 0.0000
## 18 97.00 -1.83 0.000 0.00000 0.0000
## 19 90.00 1.70 0.000 0.00000 0.0000
## 20 61.00 -1.75 0.000 0.00000 0.0000
## 21 87.00 0.19 0.000 0.00000 0.0000
## 22 96.89 -1.49 1.571 0.01887 0.1378
## 23 78.00 0.94 0.000 0.00000 0.0000
## 24 59.00 -1.12 0.000 0.00000 0.0000
## 25 75.00 -0.28 0.000 0.00000 0.0000
## 26 79.00 -0.60 0.000 0.00000 0.0000
## 27 64.00 0.86 0.000 0.00000 0.0000
## 28 54.00 -0.14 0.000 0.00000 0.0000
## 29 100.00 -1.53 0.000 NA 0.0000
## 30 67.00 -2.43 0.000 0.00000 0.0000
## 31 101.00 2.31 0.000 0.00000 0.0000
## 32 67.00 -2.00 0.000 0.03922 0.1993
## 33 67.00 2.97 1.571 0.01923 0.1391
## 34 61.17 -2.47 0.000 0.04167 0.2056
## 35 68.56 1.93 0.000 0.05556 0.2379
## 36 182.00 -1.72 0.000 0.04487 0.2134
## 37 50.00 2.14 0.000 0.00000 0.0000
## 38 88.96 -2.19 0.000 0.10959 0.3374
## 39 50.00 1.42 0.000 0.00000 0.0000
## 40 82.41 -0.85 0.000 0.04412 0.2116
## 41 52.00 1.84 1.571 0.02000 0.1419
## 42 82.23 -1.05 0.000 0.04225 0.2070
## 43 94.00 -0.84 0.000 NA 0.0000
## 44 100.00 -2.27 0.000 0.00000 0.0000
## 45 83.00 1.12 0.000 0.00000 0.0000
## 46 91.00 -1.46 0.000 0.00000 0.0000
## 47 91.00 3.13 0.000 0.00000 0.0000
## 48 99.00 -2.81 0.000 0.00000 0.0000
## 49 87.00 2.14 0.000 0.00000 0.0000
## 50 93.00 -1.42 0.000 0.00000 0.0000
## 51 98.14 2.58 1.571 0.01136 0.1068
## 52 98.00 -2.57 0.000 0.00000 0.0000
## 53 88.25 2.05 0.000 0.06250 0.2527
## 54 90.00 -0.78 0.000 0.04000 0.2014
## 55 86.00 2.39 0.000 0.00000 0.0000
## 56 86.48 -1.66 0.000 0.04478 0.2132
## 57 89.00 -1.50 0.000 NA 0.0000
## 58 97.00 -1.63 0.000 0.00000 0.0000
## 59 84.00 0.87 0.000 0.00000 0.0000
## 60 85.00 -1.83 0.000 0.00000 0.0000
## 61 89.00 1.70 0.000 0.00000 0.0000
## 62 96.00 -1.75 0.000 0.00000 0.0000
## 63 79.00 0.19 0.000 0.00000 0.0000
## 64 93.92 -1.49 1.571 0.01923 0.1391
## 65 80.00 0.94 0.000 0.00000 0.0000
## 66 87.67 -1.12 1.571 0.01667 0.1295
## 67 82.79 -0.28 1.571 0.01786 0.1340
## 68 84.49 -0.60 1.571 0.01493 0.1225
## 69 67.22 0.86 1.571 0.02222 0.1496
## 70 96.60 -0.14 0.000 0.02597 0.1619
## 71 101.00 -1.53 0.000 NA 0.0000
## 72 89.00 -2.43 0.000 0.00000 0.0000
## 73 107.00 2.31 0.000 0.00000 0.0000
## 74 89.00 -2.00 1.571 0.01250 0.1120
## 75 89.00 2.97 0.000 0.02532 0.1598
## 76 96.16 -2.47 1.571 0.01163 0.1080
## 77 86.00 1.93 0.000 0.00000 0.0000
## 78 98.09 -1.72 1.571 0.01087 0.1044
## 79 78.55 2.14 0.000 0.04545 0.2148
## 80 96.23 -2.19 0.000 0.07229 0.2722
## 81 82.35 1.42 0.000 0.07353 0.2746
## 82 87.56 -0.85 0.000 0.05556 0.2379
## 83 70.69 1.84 1.571 0.01695 0.1306
## 84 88.50 -1.05 0.000 0.02500 0.1588
## 85 94.00 -0.84 0.000 NA 0.0000
## 86 74.00 -2.27 0.000 0.00000 0.0000
## 87 93.00 1.12 0.000 0.00000 0.0000
## 88 133.00 -1.46 0.000 0.00000 0.0000
## 89 80.00 3.13 0.000 0.00000 0.0000
## 90 131.43 -2.81 0.000 0.08434 0.2947
## 91 91.00 2.14 1.571 0.01205 0.1100
## 92 94.45 -1.42 0.000 0.03448 0.1868
## 93 92.00 2.58 0.000 0.08451 0.2950
## 94 92.00 -2.57 0.000 0.13580 0.3774
## 95 93.00 2.05 0.000 0.00000 0.0000
## 96 104.00 -0.78 0.000 0.08333 0.2928
## 97 94.00 2.39 0.000 0.06667 0.2612
## 98 93.00 -1.66 0.000 0.02857 0.1698
## 99 43.00 -1.50 0.000 NA 0.0000
## 100 80.00 -1.63 0.000 0.00000 0.0000
## 101 85.00 0.87 0.000 0.00000 0.0000
## 102 55.00 -1.83 0.000 0.00000 0.0000
## 103 91.00 1.70 0.000 0.00000 0.0000
## 104 62.00 -1.75 0.000 0.00000 0.0000
## 105 76.82 0.19 1.571 0.01818 0.1353
## 106 65.00 -1.49 0.000 0.00000 0.0000
## 107 37.00 0.94 0.000 0.00000 0.0000
## 108 83.00 -1.12 0.000 0.00000 0.0000
## 109 124.08 -0.28 0.000 0.05085 0.2274
## 110 66.39 -0.60 0.000 0.03390 0.1852
## 111 94.45 0.86 1.571 0.01449 0.1207
## 112 84.00 -0.14 0.000 0.08000 0.2868
## 113 1.00 -1.53 0.000 NA 0.0000
## 114 78.00 -2.43 0.000 0.00000 0.0000
## 115 82.00 2.31 0.000 0.00000 0.0000
## 116 91.76 -2.00 0.000 0.06757 0.2630
## 117 105.33 2.97 0.000 0.03333 0.1836
## 118 84.76 -2.47 0.000 0.04762 0.2200
## 119 112.75 1.93 0.000 0.13750 0.3799
## 120 132.94 -1.72 0.000 0.12941 0.3680
## 121 99.54 2.14 0.000 0.11538 0.3466
## 122 96.20 -2.19 0.000 0.12195 0.3567
## 123 114.00 1.42 0.000 0.00000 0.0000
## 124 96.67 -0.85 0.000 0.10667 0.3327
## 125 71.00 1.84 0.000 0.00000 0.0000
## 126 114.50 -1.05 0.000 0.12500 0.3614
#First we will find the time in days between the threshold temp and the peak brooding
peakbrood<-ddply(reproanalysis,.(Site,Pop),subset,Brooders==max(Brooders, na.rm=T))
print(peakbrood)
##      X       Date       Site Temp Pop Brooders Gaping Percent Dead Closed
## 1 56 2014-08-08 Fidalgo 11 H 3 67 4.478 0 15
## 2 14 2014-08-08 Fidalgo 11 N 5 89 5.618 0 10
## 3 94 2014-07-11 Fidalgo 16 S 11 81 13.580 0 11
## 4 70 2014-08-06 Manchester 18 H 2 77 2.597 12 5
## 5 22 2014-06-25 Manchester 10 N 1 53 1.887 23 19
## 6 112 2014-08-06 Manchester 18 S 4 50 8.000 11 15
## 7 80 2014-07-10 Oyster Bay 16 H 6 83 7.229 3 3
## 8 38 2014-07-10 Oyster Bay 16 N 8 73 10.959 3 2
## 9 119 2014-06-19 Oyster Bay 16 S 11 80 13.750 12 7
## 10 120 2014-06-26 Oyster Bay 14 S 11 85 12.941 10 25
## Total Tide arcsinbrooders prop arcsinprop
## 1 86.48 -1.66 0.000 0.04478 0.2132
## 2 104.62 -1.66 0.000 0.05618 0.2393
## 3 92.00 -2.57 0.000 0.13580 0.3774
## 4 96.60 -0.14 0.000 0.02597 0.1619
## 5 96.89 -1.49 1.571 0.01887 0.1378
## 6 84.00 -0.14 0.000 0.08000 0.2868
## 7 96.23 -2.19 0.000 0.07229 0.2722
## 8 88.96 -2.19 0.000 0.10959 0.3374
## 9 112.75 1.93 0.000 0.13750 0.3799
## 10 132.94 -1.72 0.000 0.12941 0.3680
#find the dates with maximum number of brooders
oysthresh=12.5)
#create a list of temps to find those above threshold temp for minimum daily temps at each site
print(oysthresh)
##           Date min_temp
## 1 2013-08-18 17.38
## 2 2013-08-19 17.38
## 3 2013-08-20 17.66
## 4 2013-08-21 17.76
## 5 2013-08-22 17.66
## 6 2013-08-23 17.76
## 7 2013-08-24 17.57
## 8 2013-08-25 17.48
## 9 2013-08-26 17.38
## 10 2013-08-27 17.09
## 11 2013-08-28 17.09
## 12 2013-08-29 17.00
## 13 2013-08-30 16.90
## 14 2013-08-31 17.09
## 15 2013-09-01 17.19
## 16 2013-09-02 17.19
## 17 2013-09-03 17.28
## 18 2013-09-04 17.48
## 19 2013-09-05 17.57
## 20 2013-09-06 17.38
## 21 2013-09-07 17.28
## 22 2013-09-08 17.48
## 23 2013-09-09 17.48
## 24 2013-09-10 17.28
## 25 2013-09-11 17.19
## 26 2013-09-12 17.09
## 27 2013-09-13 17.19
## 28 2013-09-14 17.09
## 29 2013-09-15 17.19
## 30 2013-09-16 17.00
## 31 2013-09-17 17.00
## 32 2013-09-18 16.81
## 33 2013-09-19 16.90
## 34 2013-09-20 16.71
## 35 2013-09-21 16.71
## 36 2013-09-22 16.33
## 37 2013-09-23 16.14
## 38 2013-09-24 15.66
## 39 2013-09-25 15.47
## 40 2013-09-26 15.38
## 41 2013-09-27 15.28
## 42 2013-09-28 15.19
## 43 2013-09-29 14.80
## 44 2013-09-30 14.42
## 45 2013-10-01 13.94
## 46 2013-10-02 14.13
## 47 2013-10-03 13.94
## 48 2013-10-04 13.94
## 49 2013-10-05 14.13
## 50 2013-10-06 13.94
## 51 2013-10-07 14.04
## 52 2013-10-10 12.59
## 53 2013-10-11 13.46
## 54 2013-10-12 13.46
## 55 2013-10-13 12.88
## 56 2013-10-14 13.17
## 57 2013-10-15 12.98
## 58 2013-10-16 13.08
## 59 2013-10-17 13.17
## 60 2013-10-18 12.79
## 61 2013-10-19 12.59
## 62 2013-10-23 12.59
## 63 2014-05-14 12.69
## 64 2014-05-15 12.59
## 65 2014-05-16 12.69
## 66 2014-05-17 13.08
## 67 2014-05-18 13.27
## 68 2014-05-19 13.17
## 69 2014-05-20 13.27
## 70 2014-05-21 13.27
## 71 2014-05-22 13.46
## 72 2014-05-23 13.17
## 73 2014-05-24 13.56
## 74 2014-05-25 13.46
## 75 2014-05-26 13.56
## 76 2014-05-27 13.56
## 77 2014-05-28 13.46
## 78 2014-05-29 13.65
## 79 2014-05-30 13.65
## 80 2014-05-31 13.85
## 81 2014-06-01 13.75
## 82 2014-06-02 14.04
## 83 2014-06-03 14.04
## 84 2014-06-04 14.04
## 85 2014-06-05 14.23
## 86 2014-06-06 13.94
## 87 2014-06-07 14.13
## 88 2014-06-08 14.04
## 89 2014-06-09 13.94
## 90 2014-06-10 14.61
## 91 2014-06-11 13.94
## 92 2014-06-12 14.61
## 93 2014-06-13 14.90
## 94 2014-06-14 14.80
## 95 2014-06-15 14.71
## 96 2014-06-16 14.42
## 97 2014-06-17 14.42
## 98 2014-06-18 14.42
## 99 2014-06-19 14.52
## 100 2014-06-20 14.52
## 101 2014-06-21 15.00
## 102 2014-06-22 14.90
## 103 2014-06-23 14.80
## 104 2014-06-24 14.80
## 105 2014-06-25 15.28
## 106 2014-06-26 15.38
## 107 2014-06-27 15.47
## 108 2014-06-28 15.66
## 109 2014-06-29 15.57
## 110 2014-06-30 15.57
## 111 2014-07-01 15.66
## 112 2014-07-02 15.57
## 113 2014-07-03 15.86
## 114 2014-07-04 16.14
## 115 2014-07-05 15.76
## 116 2014-07-06 15.66
## 117 2014-07-07 16.24
## 118 2014-07-08 16.24
## 119 2014-07-09 16.24
## 120 2014-07-10 16.52
## 121 2014-07-11 17.19
## 122 2014-07-12 17.19
## 123 2014-07-13 17.28
## 124 2014-07-14 17.48
## 125 2014-07-15 17.19
## 126 2014-07-16 17.66
## 127 2014-07-17 17.48
## 128 2014-07-18 17.48
## 129 2014-07-19 17.19
## 130 2014-07-20 17.19
## 131 2014-07-21 17.28
## 132 2014-07-22 17.09
## 133 2014-07-23 17.00
## 134 2014-07-24 17.00
## 135 2014-07-25 16.90
## 136 2014-07-26 17.00
## 137 2014-07-27 17.09
## 138 2014-07-28 17.19
## 139 2014-07-29 17.38
## 140 2014-07-30 17.57
## 141 2014-07-31 17.76
## 142 2014-08-01 17.86
## 143 2014-08-02 17.76
## 144 2014-08-03 17.86
## 145 2014-08-04 17.48
## 146 2014-08-05 17.57
## 147 2014-08-06 17.76
## 148 2014-08-07 17.76
## 149 2014-08-08 17.95
## 150 2014-08-09 18.05
## 151 2014-08-10 18.24
## 152 2014-08-11 18.43
## 153 2014-08-12 18.05
## 154 2014-08-13 18.05
## 155 2014-08-14 18.05
## 156 2014-08-15 17.95
## 157 2014-08-16 17.86
## 158 2014-08-17 17.76
## 159 2014-08-18 17.66
## 160 2014-08-19 17.38
## 161 2014-08-20 17.86
## 162 2014-08-21 17.66
## 163 2014-08-22 17.76
## 164 2014-08-23 17.76
## 165 2014-08-24 17.66
## 166 2014-08-25 17.76
## 167 2014-08-26 17.76
## 168 2014-08-27 17.76
## 169 2014-08-28 17.86
## 170 2014-08-29 18.05
## 171 2014-08-30 17.76
## 172 2014-08-31 17.48
## 173 2014-09-01 17.48
## 174 2014-09-02 17.28
## 175 2014-09-03 17.19
## 176 2014-09-04 17.09
## 177 2014-09-05 17.38
## 178 2014-09-06 17.28
## 179 2014-09-07 17.38
## 180 2014-09-08 17.28
## 181 2014-09-09 17.28
## 182 2014-09-10 17.19
## 183 2014-09-11 17.09
## 184 2014-09-12 16.90
## 185 2014-09-13 16.81
## 186 2014-09-14 16.62
## 187 2014-09-15 16.62
## 188 2014-09-16 16.62
## 189 2014-09-17 16.71
## 190 2014-09-18 16.52
## 191 2014-09-19 16.62
fidthresh=12.5)
View(fidthresh)
manthresh=12.5)
View(manthresh)
peakbrood$Date<-as.Date(peakbrood$Date)
oysthresh$Date<-as.Date(oysthresh$Date)
fidthresh$Date<-as.Date(fidthresh$Date)
manthresh$Date<-as.Date(manthresh$Date)
#make sure everything works as a Date in R after producing all the threshold temp data
d<-c("2014-06-03","2014-06-08","2014-05-14")
#dates visually confirmed for threshold temps
p<-c("Fidalgo","Manchester","Oyster Bay")
thresholddate<-data.frame(p,d)
thresholddate$d<-as.Date(thresholddate$d)
peakthresh<-merge(peakbrood,thresholddate,by.x="Site",by.y="p",all=F)
print(peakthresh)
##          Site   X       Date Temp Pop Brooders Gaping Percent Dead Closed
## 1 Fidalgo 56 2014-08-08 11 H 3 67 4.478 0 15
## 2 Fidalgo 14 2014-08-08 11 N 5 89 5.618 0 10
## 3 Fidalgo 94 2014-07-11 16 S 11 81 13.580 0 11
## 4 Manchester 70 2014-08-06 18 H 2 77 2.597 12 5
## 5 Manchester 22 2014-06-25 10 N 1 53 1.887 23 19
## 6 Manchester 112 2014-08-06 18 S 4 50 8.000 11 15
## 7 Oyster Bay 80 2014-07-10 16 H 6 83 7.229 3 3
## 8 Oyster Bay 38 2014-07-10 16 N 8 73 10.959 3 2
## 9 Oyster Bay 119 2014-06-19 16 S 11 80 13.750 12 7
## 10 Oyster Bay 120 2014-06-26 14 S 11 85 12.941 10 25
## Total Tide arcsinbrooders prop arcsinprop d
## 1 86.48 -1.66 0.000 0.04478 0.2132 2014-06-03
## 2 104.62 -1.66 0.000 0.05618 0.2393 2014-06-03
## 3 92.00 -2.57 0.000 0.13580 0.3774 2014-06-03
## 4 96.60 -0.14 0.000 0.02597 0.1619 2014-06-08
## 5 96.89 -1.49 1.571 0.01887 0.1378 2014-06-08
## 6 84.00 -0.14 0.000 0.08000 0.2868 2014-06-08
## 7 96.23 -2.19 0.000 0.07229 0.2722 2014-05-14
## 8 88.96 -2.19 0.000 0.10959 0.3374 2014-05-14
## 9 112.75 1.93 0.000 0.13750 0.3799 2014-05-14
## 10 132.94 -1.72 0.000 0.12941 0.3680 2014-05-14
#create a data frame that compares dates for threshold and peak spawning dates
peakthresh$time_to_peak<-difftime(peakthresh$Date,peakthresh$d,units="days")
#finds the difference in days between threshold temp and peak spawning
print(peakthresh)
##          Site   X       Date Temp Pop Brooders Gaping Percent Dead Closed
## 1 Fidalgo 56 2014-08-08 11 H 3 67 4.478 0 15
## 2 Fidalgo 14 2014-08-08 11 N 5 89 5.618 0 10
## 3 Fidalgo 94 2014-07-11 16 S 11 81 13.580 0 11
## 4 Manchester 70 2014-08-06 18 H 2 77 2.597 12 5
## 5 Manchester 22 2014-06-25 10 N 1 53 1.887 23 19
## 6 Manchester 112 2014-08-06 18 S 4 50 8.000 11 15
## 7 Oyster Bay 80 2014-07-10 16 H 6 83 7.229 3 3
## 8 Oyster Bay 38 2014-07-10 16 N 8 73 10.959 3 2
## 9 Oyster Bay 119 2014-06-19 16 S 11 80 13.750 12 7
## 10 Oyster Bay 120 2014-06-26 14 S 11 85 12.941 10 25
## Total Tide arcsinbrooders prop arcsinprop d time_to_peak
## 1 86.48 -1.66 0.000 0.04478 0.2132 2014-06-03 66 days
## 2 104.62 -1.66 0.000 0.05618 0.2393 2014-06-03 66 days
## 3 92.00 -2.57 0.000 0.13580 0.3774 2014-06-03 38 days
## 4 96.60 -0.14 0.000 0.02597 0.1619 2014-06-08 59 days
## 5 96.89 -1.49 1.571 0.01887 0.1378 2014-06-08 17 days
## 6 84.00 -0.14 0.000 0.08000 0.2868 2014-06-08 59 days
## 7 96.23 -2.19 0.000 0.07229 0.2722 2014-05-14 57 days
## 8 88.96 -2.19 0.000 0.10959 0.3374 2014-05-14 57 days
## 9 112.75 1.93 0.000 0.13750 0.3799 2014-05-14 36 days
## 10 132.94 -1.72 0.000 0.12941 0.3680 2014-05-14 43 days
peakthresh2<-peakthresh[c("Date","Site","Pop","Brooders","d","time_to_peak")]
#subsets df to only relevant information
peakthresh2<-rename(peakthresh2,c('Date'='Peak_Date',"Site"="Site","Pop"="Pop","Brooders"="Brooders","d"="Threshold Date","time_to_peak"="Days_to_Peak"))
#renames df columns to more meaningful names
print(peakthresh2)
##     Peak_Date       Site Pop Brooders Threshold Date Days_to_Peak
## 1 2014-08-08 Fidalgo H 3 2014-06-03 66 days
## 2 2014-08-08 Fidalgo N 5 2014-06-03 66 days
## 3 2014-07-11 Fidalgo S 11 2014-06-03 38 days
## 4 2014-08-06 Manchester H 2 2014-06-08 59 days
## 5 2014-06-25 Manchester N 1 2014-06-08 17 days
## 6 2014-08-06 Manchester S 4 2014-06-08 59 days
## 7 2014-07-10 Oyster Bay H 6 2014-05-14 57 days
## 8 2014-07-10 Oyster Bay N 8 2014-05-14 57 days
## 9 2014-06-19 Oyster Bay S 11 2014-05-14 36 days
## 10 2014-06-26 Oyster Bay S 11 2014-05-14 43 days
#next we want to find the degree days from minimum winter temp to spawning peak
#looking at previously generated temp graphs we decided that 8 was minimum winter temp
#we have to visually confirm when the temps continually increase from 8 to spawning
oysdd=8)
#subsets minimum temp data to find dates with temps above 8 C.
oysdd="2014-03-06"),]
#after visually confirming the initial temp date we then subset the data from this point on
print(oysdd)
##           Date min_temp
## 201 2014-03-06 8.082
## 202 2014-03-07 8.282
## 203 2014-03-08 8.382
## 204 2014-03-09 8.382
## 205 2014-03-10 8.382
## 206 2014-03-11 8.879
## 207 2014-03-12 8.779
## 208 2014-03-13 8.779
## 209 2014-03-14 8.680
## 210 2014-03-15 8.779
## 211 2014-03-16 8.879
## 212 2014-03-17 8.779
## 213 2014-03-18 8.779
## 214 2014-03-19 8.879
## 215 2014-03-20 8.680
## 216 2014-03-21 8.779
## 217 2014-03-22 8.879
## 218 2014-03-23 8.879
## 219 2014-03-24 8.978
## 220 2014-03-25 8.978
## 221 2014-03-26 9.176
## 222 2014-03-27 9.176
## 223 2014-03-28 9.275
## 224 2014-03-29 9.275
## 225 2014-03-30 9.176
## 226 2014-03-31 9.275
## 227 2014-04-01 9.275
## 228 2014-04-02 9.373
## 229 2014-04-03 9.571
## 230 2014-04-04 9.571
## 231 2014-04-05 9.669
## 232 2014-04-06 9.571
## 233 2014-04-07 9.669
## 234 2014-04-08 9.669
## 235 2014-04-09 9.866
## 236 2014-04-10 9.866
## 237 2014-04-11 10.063
## 238 2014-04-12 10.161
## 239 2014-04-13 10.455
## 240 2014-04-14 10.553
## 241 2014-04-15 10.748
## 242 2014-04-16 10.944
## 243 2014-04-17 10.748
## 244 2014-04-18 10.651
## 245 2014-04-19 10.651
## 246 2014-04-20 10.651
## 247 2014-04-21 10.553
## 248 2014-04-22 10.553
## 249 2014-04-23 10.651
## 250 2014-04-24 10.651
## 251 2014-04-25 10.846
## 252 2014-04-26 10.748
## 253 2014-04-27 10.748
## 254 2014-04-28 10.846
## 255 2014-04-29 10.944
## 256 2014-04-30 11.139
## 257 2014-05-01 11.236
## 258 2014-05-02 11.431
## 259 2014-05-03 12.013
## 260 2014-05-04 11.819
## 261 2014-05-05 11.722
## 262 2014-05-06 11.722
## 263 2014-05-07 11.625
## 264 2014-05-08 11.625
## 265 2014-05-09 11.625
## 266 2014-05-10 11.819
## 267 2014-05-11 11.916
## 268 2014-05-12 12.013
## 269 2014-05-13 12.013
## 270 2014-05-14 12.690
## 271 2014-05-15 12.594
## 272 2014-05-16 12.690
## 273 2014-05-17 13.076
## 274 2014-05-18 13.269
## 275 2014-05-19 13.173
## 276 2014-05-20 13.269
## 277 2014-05-21 13.269
## 278 2014-05-22 13.461
## 279 2014-05-23 13.173
## 280 2014-05-24 13.558
## 281 2014-05-25 13.461
## 282 2014-05-26 13.558
## 283 2014-05-27 13.558
## 284 2014-05-28 13.461
## 285 2014-05-29 13.654
## 286 2014-05-30 13.654
## 287 2014-05-31 13.846
## 288 2014-06-01 13.750
## 289 2014-06-02 14.038
## 290 2014-06-03 14.038
## 291 2014-06-04 14.038
## 292 2014-06-05 14.230
## 293 2014-06-06 13.942
## 294 2014-06-07 14.134
## 295 2014-06-08 14.038
## 296 2014-06-09 13.942
## 297 2014-06-10 14.613
## 298 2014-06-11 13.942
## 299 2014-06-12 14.613
## 300 2014-06-13 14.900
## 301 2014-06-14 14.804
## 302 2014-06-15 14.709
## 303 2014-06-16 14.421
## 304 2014-06-17 14.421
## 305 2014-06-18 14.421
## 306 2014-06-19 14.517
## 307 2014-06-20 14.517
## 308 2014-06-21 14.996
## 309 2014-06-22 14.900
## 310 2014-06-23 14.804
## 311 2014-06-24 14.804
## 312 2014-06-25 15.282
## 313 2014-06-26 15.378
## 314 2014-06-27 15.473
## 315 2014-06-28 15.664
## 316 2014-06-29 15.569
## 317 2014-06-30 15.569
## 318 2014-07-01 15.664
## 319 2014-07-02 15.569
## 320 2014-07-03 15.855
## 321 2014-07-04 16.141
## 322 2014-07-05 15.760
## 323 2014-07-06 15.664
## 324 2014-07-07 16.237
## 325 2014-07-08 16.237
## 326 2014-07-09 16.237
## 327 2014-07-10 16.523
## 328 2014-07-11 17.189
## 329 2014-07-12 17.189
## 330 2014-07-13 17.284
## 331 2014-07-14 17.475
## 332 2014-07-15 17.189
## 333 2014-07-16 17.665
## 334 2014-07-17 17.475
## 335 2014-07-18 17.475
## 336 2014-07-19 17.189
## 337 2014-07-20 17.189
## 338 2014-07-21 17.284
## 339 2014-07-22 17.094
## 340 2014-07-23 16.999
## 341 2014-07-24 16.999
## 342 2014-07-25 16.903
## 343 2014-07-26 16.999
## 344 2014-07-27 17.094
## 345 2014-07-28 17.189
## 346 2014-07-29 17.379
## 347 2014-07-30 17.570
## 348 2014-07-31 17.760
## 349 2014-08-01 17.855
## 350 2014-08-02 17.760
## 351 2014-08-03 17.855
## 352 2014-08-04 17.475
## 353 2014-08-05 17.570
## 354 2014-08-06 17.760
## 355 2014-08-07 17.760
## 356 2014-08-08 17.950
## 357 2014-08-09 18.045
## 358 2014-08-10 18.236
## 359 2014-08-11 18.426
## 360 2014-08-12 18.045
## 361 2014-08-13 18.045
## 362 2014-08-14 18.045
## 363 2014-08-15 17.950
## 364 2014-08-16 17.855
## 365 2014-08-17 17.760
## 366 2014-08-18 17.665
## 367 2014-08-19 17.379
## 368 2014-08-20 17.855
## 369 2014-08-21 17.665
## 370 2014-08-22 17.760
## 371 2014-08-23 17.760
## 372 2014-08-24 17.665
## 373 2014-08-25 17.760
## 374 2014-08-26 17.760
## 375 2014-08-27 17.760
## 376 2014-08-28 17.855
## 377 2014-08-29 18.045
## 378 2014-08-30 17.760
## 379 2014-08-31 17.475
## 380 2014-09-01 17.475
## 381 2014-09-02 17.284
## 382 2014-09-03 17.189
## 383 2014-09-04 17.094
## 384 2014-09-05 17.379
## 385 2014-09-06 17.284
## 386 2014-09-07 17.379
## 387 2014-09-08 17.284
## 388 2014-09-09 17.284
## 389 2014-09-10 17.189
## 390 2014-09-11 17.094
## 391 2014-09-12 16.903
## 392 2014-09-13 16.808
## 393 2014-09-14 16.618
## 394 2014-09-15 16.618
## 395 2014-09-16 16.618
## 396 2014-09-17 16.713
## 397 2014-09-18 16.523
## 398 2014-09-19 16.618
#we have to subset temp data to just the time frame between 8C beginning and peak spawn for each pop at each site
#luckily two pops at each site had the same spawn time data so we use that
oyshndd<-oysdd[c(oysdd$Date<="2014-07-10"),]
oyssdd<-oysdd[c(oysdd$Date<="2014-06-19"),]
print(oyshndd)
##           Date min_temp
## 201 2014-03-06 8.082
## 202 2014-03-07 8.282
## 203 2014-03-08 8.382
## 204 2014-03-09 8.382
## 205 2014-03-10 8.382
## 206 2014-03-11 8.879
## 207 2014-03-12 8.779
## 208 2014-03-13 8.779
## 209 2014-03-14 8.680
## 210 2014-03-15 8.779
## 211 2014-03-16 8.879
## 212 2014-03-17 8.779
## 213 2014-03-18 8.779
## 214 2014-03-19 8.879
## 215 2014-03-20 8.680
## 216 2014-03-21 8.779
## 217 2014-03-22 8.879
## 218 2014-03-23 8.879
## 219 2014-03-24 8.978
## 220 2014-03-25 8.978
## 221 2014-03-26 9.176
## 222 2014-03-27 9.176
## 223 2014-03-28 9.275
## 224 2014-03-29 9.275
## 225 2014-03-30 9.176
## 226 2014-03-31 9.275
## 227 2014-04-01 9.275
## 228 2014-04-02 9.373
## 229 2014-04-03 9.571
## 230 2014-04-04 9.571
## 231 2014-04-05 9.669
## 232 2014-04-06 9.571
## 233 2014-04-07 9.669
## 234 2014-04-08 9.669
## 235 2014-04-09 9.866
## 236 2014-04-10 9.866
## 237 2014-04-11 10.063
## 238 2014-04-12 10.161
## 239 2014-04-13 10.455
## 240 2014-04-14 10.553
## 241 2014-04-15 10.748
## 242 2014-04-16 10.944
## 243 2014-04-17 10.748
## 244 2014-04-18 10.651
## 245 2014-04-19 10.651
## 246 2014-04-20 10.651
## 247 2014-04-21 10.553
## 248 2014-04-22 10.553
## 249 2014-04-23 10.651
## 250 2014-04-24 10.651
## 251 2014-04-25 10.846
## 252 2014-04-26 10.748
## 253 2014-04-27 10.748
## 254 2014-04-28 10.846
## 255 2014-04-29 10.944
## 256 2014-04-30 11.139
## 257 2014-05-01 11.236
## 258 2014-05-02 11.431
## 259 2014-05-03 12.013
## 260 2014-05-04 11.819
## 261 2014-05-05 11.722
## 262 2014-05-06 11.722
## 263 2014-05-07 11.625
## 264 2014-05-08 11.625
## 265 2014-05-09 11.625
## 266 2014-05-10 11.819
## 267 2014-05-11 11.916
## 268 2014-05-12 12.013
## 269 2014-05-13 12.013
## 270 2014-05-14 12.690
## 271 2014-05-15 12.594
## 272 2014-05-16 12.690
## 273 2014-05-17 13.076
## 274 2014-05-18 13.269
## 275 2014-05-19 13.173
## 276 2014-05-20 13.269
## 277 2014-05-21 13.269
## 278 2014-05-22 13.461
## 279 2014-05-23 13.173
## 280 2014-05-24 13.558
## 281 2014-05-25 13.461
## 282 2014-05-26 13.558
## 283 2014-05-27 13.558
## 284 2014-05-28 13.461
## 285 2014-05-29 13.654
## 286 2014-05-30 13.654
## 287 2014-05-31 13.846
## 288 2014-06-01 13.750
## 289 2014-06-02 14.038
## 290 2014-06-03 14.038
## 291 2014-06-04 14.038
## 292 2014-06-05 14.230
## 293 2014-06-06 13.942
## 294 2014-06-07 14.134
## 295 2014-06-08 14.038
## 296 2014-06-09 13.942
## 297 2014-06-10 14.613
## 298 2014-06-11 13.942
## 299 2014-06-12 14.613
## 300 2014-06-13 14.900
## 301 2014-06-14 14.804
## 302 2014-06-15 14.709
## 303 2014-06-16 14.421
## 304 2014-06-17 14.421
## 305 2014-06-18 14.421
## 306 2014-06-19 14.517
## 307 2014-06-20 14.517
## 308 2014-06-21 14.996
## 309 2014-06-22 14.900
## 310 2014-06-23 14.804
## 311 2014-06-24 14.804
## 312 2014-06-25 15.282
## 313 2014-06-26 15.378
## 314 2014-06-27 15.473
## 315 2014-06-28 15.664
## 316 2014-06-29 15.569
## 317 2014-06-30 15.569
## 318 2014-07-01 15.664
## 319 2014-07-02 15.569
## 320 2014-07-03 15.855
## 321 2014-07-04 16.141
## 322 2014-07-05 15.760
## 323 2014-07-06 15.664
## 324 2014-07-07 16.237
## 325 2014-07-08 16.237
## 326 2014-07-09 16.237
## 327 2014-07-10 16.523
print(oyssdd)
##           Date min_temp
## 201 2014-03-06 8.082
## 202 2014-03-07 8.282
## 203 2014-03-08 8.382
## 204 2014-03-09 8.382
## 205 2014-03-10 8.382
## 206 2014-03-11 8.879
## 207 2014-03-12 8.779
## 208 2014-03-13 8.779
## 209 2014-03-14 8.680
## 210 2014-03-15 8.779
## 211 2014-03-16 8.879
## 212 2014-03-17 8.779
## 213 2014-03-18 8.779
## 214 2014-03-19 8.879
## 215 2014-03-20 8.680
## 216 2014-03-21 8.779
## 217 2014-03-22 8.879
## 218 2014-03-23 8.879
## 219 2014-03-24 8.978
## 220 2014-03-25 8.978
## 221 2014-03-26 9.176
## 222 2014-03-27 9.176
## 223 2014-03-28 9.275
## 224 2014-03-29 9.275
## 225 2014-03-30 9.176
## 226 2014-03-31 9.275
## 227 2014-04-01 9.275
## 228 2014-04-02 9.373
## 229 2014-04-03 9.571
## 230 2014-04-04 9.571
## 231 2014-04-05 9.669
## 232 2014-04-06 9.571
## 233 2014-04-07 9.669
## 234 2014-04-08 9.669
## 235 2014-04-09 9.866
## 236 2014-04-10 9.866
## 237 2014-04-11 10.063
## 238 2014-04-12 10.161
## 239 2014-04-13 10.455
## 240 2014-04-14 10.553
## 241 2014-04-15 10.748
## 242 2014-04-16 10.944
## 243 2014-04-17 10.748
## 244 2014-04-18 10.651
## 245 2014-04-19 10.651
## 246 2014-04-20 10.651
## 247 2014-04-21 10.553
## 248 2014-04-22 10.553
## 249 2014-04-23 10.651
## 250 2014-04-24 10.651
## 251 2014-04-25 10.846
## 252 2014-04-26 10.748
## 253 2014-04-27 10.748
## 254 2014-04-28 10.846
## 255 2014-04-29 10.944
## 256 2014-04-30 11.139
## 257 2014-05-01 11.236
## 258 2014-05-02 11.431
## 259 2014-05-03 12.013
## 260 2014-05-04 11.819
## 261 2014-05-05 11.722
## 262 2014-05-06 11.722
## 263 2014-05-07 11.625
## 264 2014-05-08 11.625
## 265 2014-05-09 11.625
## 266 2014-05-10 11.819
## 267 2014-05-11 11.916
## 268 2014-05-12 12.013
## 269 2014-05-13 12.013
## 270 2014-05-14 12.690
## 271 2014-05-15 12.594
## 272 2014-05-16 12.690
## 273 2014-05-17 13.076
## 274 2014-05-18 13.269
## 275 2014-05-19 13.173
## 276 2014-05-20 13.269
## 277 2014-05-21 13.269
## 278 2014-05-22 13.461
## 279 2014-05-23 13.173
## 280 2014-05-24 13.558
## 281 2014-05-25 13.461
## 282 2014-05-26 13.558
## 283 2014-05-27 13.558
## 284 2014-05-28 13.461
## 285 2014-05-29 13.654
## 286 2014-05-30 13.654
## 287 2014-05-31 13.846
## 288 2014-06-01 13.750
## 289 2014-06-02 14.038
## 290 2014-06-03 14.038
## 291 2014-06-04 14.038
## 292 2014-06-05 14.230
## 293 2014-06-06 13.942
## 294 2014-06-07 14.134
## 295 2014-06-08 14.038
## 296 2014-06-09 13.942
## 297 2014-06-10 14.613
## 298 2014-06-11 13.942
## 299 2014-06-12 14.613
## 300 2014-06-13 14.900
## 301 2014-06-14 14.804
## 302 2014-06-15 14.709
## 303 2014-06-16 14.421
## 304 2014-06-17 14.421
## 305 2014-06-18 14.421
## 306 2014-06-19 14.517
#once these subsets are created we need to create a column of the difference between the 8 C minimum
#and the daily minimum temp for each subsets
oyshndd$tempdiff<-oyshndd$min_temp-8
oyssdd$tempdiff<-oyssdd$min_temp-8
#use this temp diff column to create the degree days between 8C minimum and the peak threshold
colSums(oyshndd[,-1])
## min_temp tempdiff 
## 1529 513
colSums(oyssdd[,-1])
## min_temp tempdiff 
## 1202.2 354.2
#we generate this same info for all pops at all sites
fiddd=8)
fiddd="2014-03-06"),]
View(fiddd)
fidhndd<-fiddd[c(fiddd$Date<="2014-08-08"),]
fidsdd<-fiddd[c(fiddd$Date<="2014-07-11"),]
View(fidhndd)
View(fidsdd)
fidhndd$tempdiff<-fidhndd$min_temp-8
fidsdd$tempdiff<-fidsdd$min_temp-8
colSums(fidhndd[,-1])
## min_temp tempdiff 
## 1697.7 449.7
colSums(fidsdd[,-1])
## min_temp tempdiff 
## 1328.6 304.6
mandd=8)
mandd="2014-03-06"),]
View(mandd)
manhsdd<-mandd[c(mandd$Date<="2014-08-06"),]
manndd<-mandd[c(mandd$Date<="2014-06-25"),]
View(manhsdd)
View(manndd)
manhsdd$tempdiff<-manhsdd$min_temp-8
manndd$tempdiff<-manndd$min_temp-8
colSums(manhsdd[,-1])
## min_temp tempdiff 
## 1723.7 491.7
colSums(manndd[,-1])
## min_temp tempdiff 
## 1141.6 245.6
#due to how R works its easier to just copy these numbers and create a data frame to merge with the peak threshold info
DegreeDays<-c("512.999","512.999","354.156","453.021","453.021","307.894","377.561","175.322","377.561")
Pop<-c("H","N","S")
Site<-c("Oyster Bay","Oyster Bay","Oyster Bay","Fidalgo","Fidalgo","Fidalgo","Manchester","Manchester","Manchester")
Degree<-data.frame(Site,Pop,DegreeDays)
#onces the Degree data frame is created it can be merged with the peakthresh2 data frame to show degree days and time to peak in the same table
peakthresh3<-merge(peakthresh2,Degree,by.x=c("Site","Pop"),by.y=c("Site","Pop"),all=T)
print(peakthresh3)
##          Site Pop  Peak_Date Brooders Threshold Date Days_to_Peak
## 1 Fidalgo H 2014-08-08 3 2014-06-03 66 days
## 2 Fidalgo N 2014-08-08 5 2014-06-03 66 days
## 3 Fidalgo S 2014-07-11 11 2014-06-03 38 days
## 4 Manchester H 2014-08-06 2 2014-06-08 59 days
## 5 Manchester N 2014-06-25 1 2014-06-08 17 days
## 6 Manchester S 2014-08-06 4 2014-06-08 59 days
## 7 Oyster Bay H 2014-07-10 6 2014-05-14 57 days
## 8 Oyster Bay N 2014-07-10 8 2014-05-14 57 days
## 9 Oyster Bay S 2014-06-19 11 2014-05-14 36 days
## 10 Oyster Bay S 2014-06-26 11 2014-05-14 43 days
## DegreeDays
## 1 453.021
## 2 453.021
## 3 307.894
## 4 377.561
## 5 175.322
## 6 377.561
## 7 512.999
## 8 512.999
## 9 354.156
## 10 354.156
#now we need to make a graph because nothing is good unless its a graph
#first we merge the three longest time frame tempdiff to create a data frame that works with ggplot2
of<-merge(oyshndd,fidhndd,by="Date",all=T,incomparables="0")
dddf<-merge(of,manhsdd,by="Date",all=T,incomparables="0")
#we need to clean up the NAs produced so that these can be graphed in ggplot2
dddf[is.na(dddf)]<-0
#Now we rename the columns to meaningful titles
dddf<-rename(dddf,c('Date'='Date','min_temp.x'='oysmin','tempdiff.x'='oystempdiff','min_temp.y'='fidmin','tempdiff.y'='fidtempdiff','min_temp'='manmin','tempdiff'='mantempdiff'))
#check the data frame to make sure that everything aligns to the X axis dates of interest with the right tempdiff numbers
print(dddf)
##           Date oysmin oystempdiff fidmin fidtempdiff manmin mantempdiff
## 1 2014-03-06 8.082 0.082 7.079 -0.921 8.082 0.0820
## 2 2014-03-07 8.282 0.282 7.280 -0.720 8.082 0.0820
## 3 2014-03-08 8.382 0.382 7.582 -0.418 8.082 0.0820
## 4 2014-03-09 8.382 0.382 7.381 -0.619 8.282 0.2820
## 5 2014-03-10 8.382 0.382 7.582 -0.418 8.282 0.2820
## 6 2014-03-11 8.879 0.879 7.782 -0.218 8.382 0.3820
## 7 2014-03-12 8.779 0.779 8.082 0.082 8.680 0.6800
## 8 2014-03-13 8.779 0.779 8.581 0.581 8.879 0.8790
## 9 2014-03-14 8.680 0.680 7.782 -0.218 8.680 0.6800
## 10 2014-03-15 8.779 0.779 7.782 -0.218 8.581 0.5810
## 11 2014-03-16 8.879 0.879 7.983 -0.017 8.481 0.4810
## 12 2014-03-17 8.779 0.779 7.682 -0.318 8.481 0.4810
## 13 2014-03-18 8.779 0.779 7.682 -0.318 8.581 0.5810
## 14 2014-03-19 8.879 0.879 7.882 -0.118 8.481 0.4810
## 15 2014-03-20 8.680 0.680 7.782 -0.218 8.382 0.3820
## 16 2014-03-21 8.779 0.779 8.182 0.182 8.481 0.4810
## 17 2014-03-22 8.879 0.879 7.983 -0.017 8.481 0.4810
## 18 2014-03-23 8.879 0.879 7.983 -0.017 8.581 0.5810
## 19 2014-03-24 8.978 0.978 8.182 0.182 8.779 0.7790
## 20 2014-03-25 8.978 0.978 8.082 0.082 8.879 0.8790
## 21 2014-03-26 9.176 1.176 7.882 -0.118 8.581 0.5810
## 22 2014-03-27 9.176 1.176 8.082 0.082 8.581 0.5810
## 23 2014-03-28 9.275 1.275 8.282 0.282 8.581 0.5810
## 24 2014-03-29 9.275 1.275 8.082 0.082 8.431 0.4315
## 25 2014-03-30 9.176 1.176 8.282 0.282 8.382 0.3820
## 26 2014-03-31 9.275 1.275 7.983 -0.017 8.481 0.4810
## 27 2014-04-01 9.275 1.275 8.581 0.581 8.581 0.5810
## 28 2014-04-02 9.373 1.373 8.481 0.481 8.680 0.6800
## 29 2014-04-03 9.571 1.571 8.481 0.481 8.680 0.6800
## 30 2014-04-04 9.571 1.571 8.282 0.282 8.581 0.5810
## 31 2014-04-05 9.669 1.669 8.382 0.382 8.680 0.6800
## 32 2014-04-06 9.571 1.571 8.382 0.382 8.779 0.7790
## 33 2014-04-07 9.669 1.669 8.680 0.680 8.978 0.9780
## 34 2014-04-08 9.669 1.669 8.879 0.879 9.127 1.1265
## 35 2014-04-09 9.866 1.866 8.680 0.680 9.176 1.1760
## 36 2014-04-10 9.866 1.866 8.779 0.779 9.669 1.6690
## 37 2014-04-11 10.063 2.063 9.077 1.077 10.161 2.1610
## 38 2014-04-12 10.161 2.161 9.176 1.176 10.602 2.6020
## 39 2014-04-13 10.455 2.455 9.373 1.373 10.357 2.3570
## 40 2014-04-14 10.553 2.553 9.669 1.669 10.161 2.1610
## 41 2014-04-15 10.748 2.748 9.176 1.176 10.161 2.1610
## 42 2014-04-16 10.944 2.944 9.275 1.275 9.768 1.7680
## 43 2014-04-17 10.748 2.748 9.472 1.472 9.275 1.2750
## 44 2014-04-18 10.651 2.651 9.077 1.077 9.472 1.4720
## 45 2014-04-19 10.651 2.651 9.275 1.275 9.275 1.2750
## 46 2014-04-20 10.651 2.651 8.978 0.978 9.275 1.2750
## 47 2014-04-21 10.553 2.553 9.275 1.275 9.275 1.2750
## 48 2014-04-22 10.553 2.553 9.176 1.176 9.373 1.3730
## 49 2014-04-23 10.651 2.651 9.571 1.571 9.472 1.4720
## 50 2014-04-24 10.651 2.651 9.275 1.275 9.472 1.4720
## 51 2014-04-25 10.846 2.846 9.472 1.472 9.472 1.4720
## 52 2014-04-26 10.748 2.748 9.472 1.472 9.373 1.3730
## 53 2014-04-27 10.748 2.748 9.275 1.275 9.176 1.1760
## 54 2014-04-28 10.846 2.846 9.373 1.373 9.275 1.2750
## 55 2014-04-29 10.944 2.944 10.161 2.161 9.275 1.2750
## 56 2014-04-30 11.139 3.139 10.357 2.357 9.275 1.2750
## 57 2014-05-01 11.236 3.236 10.259 2.259 9.768 1.7680
## 58 2014-05-02 11.431 3.431 10.161 2.161 9.965 1.9650
## 59 2014-05-03 12.013 4.013 9.866 1.866 9.669 1.6690
## 60 2014-05-04 11.819 3.819 9.965 1.965 9.669 1.6690
## 61 2014-05-05 11.722 3.722 9.965 1.965 9.768 1.7680
## 62 2014-05-06 11.722 3.722 10.063 2.063 9.866 1.8660
## 63 2014-05-07 11.625 3.625 10.357 2.357 10.161 2.1610
## 64 2014-05-08 11.625 3.625 10.259 2.259 9.965 1.9650
## 65 2014-05-09 11.625 3.625 9.965 1.965 10.063 2.0630
## 66 2014-05-10 11.819 3.819 10.259 2.259 9.866 1.8660
## 67 2014-05-11 11.916 3.916 10.553 2.553 9.965 1.9650
## 68 2014-05-12 12.013 4.013 11.041 3.041 10.357 2.3570
## 69 2014-05-13 12.013 4.013 12.304 4.304 11.285 3.2850
## 70 2014-05-14 12.690 4.690 12.594 4.594 11.819 3.8190
## 71 2014-05-15 12.594 4.594 11.916 3.916 11.625 3.6250
## 72 2014-05-16 12.690 4.690 11.041 3.041 11.041 3.0410
## 73 2014-05-17 13.076 5.076 11.041 3.041 10.504 2.5040
## 74 2014-05-18 13.269 5.269 11.139 3.139 10.553 2.5530
## 75 2014-05-19 13.173 5.173 10.944 2.944 10.602 2.6020
## 76 2014-05-20 13.269 5.269 11.041 3.041 10.651 2.6510
## 77 2014-05-21 13.269 5.269 10.748 2.748 10.944 2.9440
## 78 2014-05-22 13.461 5.461 11.139 3.139 11.674 3.6735
## 79 2014-05-23 13.173 5.173 10.846 2.846 11.916 3.9160
## 80 2014-05-24 13.558 5.558 10.748 2.748 11.431 3.4310
## 81 2014-05-25 13.461 5.461 11.041 3.041 11.625 3.6250
## 82 2014-05-26 13.558 5.558 10.846 2.846 11.479 3.4795
## 83 2014-05-27 13.558 5.558 10.748 2.748 11.041 3.0410
## 84 2014-05-28 13.461 5.461 11.528 3.528 11.236 3.2360
## 85 2014-05-29 13.654 5.654 10.944 2.944 11.041 3.0410
## 86 2014-05-30 13.654 5.654 11.041 3.041 10.846 2.8460
## 87 2014-05-31 13.846 5.846 11.916 3.916 11.139 3.1390
## 88 2014-06-01 13.750 5.750 11.722 3.722 11.236 3.2360
## 89 2014-06-02 14.038 6.038 11.819 3.819 11.334 3.3340
## 90 2014-06-03 14.038 6.038 13.173 5.173 11.528 3.5280
## 91 2014-06-04 14.038 6.038 12.883 4.883 11.528 3.5280
## 92 2014-06-05 14.230 6.230 13.558 5.558 11.625 3.6250
## 93 2014-06-06 13.942 5.942 14.613 6.613 12.013 4.0130
## 94 2014-06-07 14.134 6.134 15.091 7.091 12.690 4.6900
## 95 2014-06-08 14.038 6.038 13.461 5.461 13.750 5.7500
## 96 2014-06-09 13.942 5.942 13.365 5.365 14.182 6.1820
## 97 2014-06-10 14.613 6.613 12.690 4.690 13.654 5.6540
## 98 2014-06-11 13.942 5.942 12.594 4.594 13.558 5.5580
## 99 2014-06-12 14.613 6.613 12.013 4.013 12.980 4.9800
## 100 2014-06-13 14.900 6.900 11.431 3.431 12.449 4.4490
## 101 2014-06-14 14.804 6.804 11.139 3.139 12.013 4.0130
## 102 2014-06-15 14.709 6.709 11.041 3.041 11.674 3.6735
## 103 2014-06-16 14.421 6.421 10.944 2.944 11.722 3.7220
## 104 2014-06-17 14.421 6.421 10.846 2.846 11.819 3.8190
## 105 2014-06-18 14.421 6.421 10.748 2.748 11.722 3.7220
## 106 2014-06-19 14.517 6.517 10.651 2.651 11.819 3.8190
## 107 2014-06-20 14.517 6.517 10.944 2.944 12.013 4.0130
## 108 2014-06-21 14.996 6.996 11.334 3.334 12.013 4.0130
## 109 2014-06-22 14.900 6.900 12.110 4.110 12.110 4.1100
## 110 2014-06-23 14.804 6.804 12.110 4.110 12.883 4.8830
## 111 2014-06-24 14.804 6.804 11.528 3.528 13.173 5.1730
## 112 2014-06-25 15.282 7.282 12.013 4.013 13.076 5.0760
## 113 2014-06-26 15.378 7.378 13.076 5.076 12.931 4.9315
## 114 2014-06-27 15.473 7.473 12.401 4.401 12.497 4.4970
## 115 2014-06-28 15.664 7.664 11.916 3.916 12.304 4.3040
## 116 2014-06-29 15.569 7.569 11.819 3.819 12.304 4.3040
## 117 2014-06-30 15.569 7.569 11.722 3.722 12.207 4.2070
## 118 2014-07-01 15.664 7.664 12.110 4.110 12.594 4.5940
## 119 2014-07-02 15.569 7.569 11.625 3.625 13.125 5.1245
## 120 2014-07-03 15.855 7.855 11.334 3.334 13.269 5.2690
## 121 2014-07-04 16.141 8.141 11.722 3.722 13.990 5.9900
## 122 2014-07-05 15.760 7.760 12.690 4.690 14.517 6.5170
## 123 2014-07-06 15.664 7.664 13.076 5.076 14.996 6.9960
## 124 2014-07-07 16.237 8.237 13.654 5.654 15.569 7.5690
## 125 2014-07-08 16.237 8.237 14.613 6.613 15.617 7.6165
## 126 2014-07-09 16.237 8.237 15.473 7.473 15.808 7.8075
## 127 2014-07-10 16.523 8.523 16.427 8.427 15.282 7.2820
## 128 2014-07-11 0.000 0.000 16.332 8.332 14.517 6.5170
## 129 2014-07-12 0.000 0.000 14.613 6.613 14.421 6.4210
## 130 2014-07-13 0.000 0.000 13.269 5.269 14.038 6.0380
## 131 2014-07-14 0.000 0.000 12.690 4.690 13.750 5.7500
## 132 2014-07-15 0.000 0.000 12.497 4.497 13.654 5.6540
## 133 2014-07-16 0.000 0.000 12.401 4.401 13.654 5.6540
## 134 2014-07-17 0.000 0.000 12.110 4.110 13.846 5.8460
## 135 2014-07-18 0.000 0.000 12.110 4.110 13.750 5.7500
## 136 2014-07-19 0.000 0.000 12.207 4.207 13.365 5.3650
## 137 2014-07-20 0.000 0.000 12.401 4.401 13.173 5.1730
## 138 2014-07-21 0.000 0.000 12.594 4.594 13.461 5.4610
## 139 2014-07-22 0.000 0.000 12.980 4.980 13.365 5.3650
## 140 2014-07-23 0.000 0.000 12.594 4.594 13.173 5.1730
## 141 2014-07-24 0.000 0.000 11.916 3.916 13.125 5.1245
## 142 2014-07-25 0.000 0.000 11.916 3.916 13.076 5.0760
## 143 2014-07-26 0.000 0.000 12.401 4.401 13.269 5.2690
## 144 2014-07-27 0.000 0.000 12.110 4.110 13.461 5.4610
## 145 2014-07-28 0.000 0.000 12.401 4.401 13.558 5.5580
## 146 2014-07-29 0.000 0.000 12.883 4.883 13.750 5.7500
## 147 2014-07-30 0.000 0.000 12.013 4.013 13.942 5.9420
## 148 2014-07-31 0.000 0.000 12.980 4.980 14.325 6.3250
## 149 2014-08-01 0.000 0.000 13.654 5.654 14.469 6.4690
## 150 2014-08-02 0.000 0.000 14.804 6.804 14.613 6.6130
## 151 2014-08-03 0.000 0.000 15.664 7.664 14.709 6.7090
## 152 2014-08-04 0.000 0.000 15.855 7.855 14.709 6.7090
## 153 2014-08-05 0.000 0.000 15.473 7.473 14.996 6.9960
## 154 2014-08-06 0.000 0.000 14.996 6.996 14.900 6.9000
## 155 2014-08-07 0.000 0.000 14.134 6.134 0.000 0.0000
## 156 2014-08-08 0.000 0.000 13.461 5.461 0.000 0.0000
#using ggplot and cumsum(cumulativesum) we can create cumulative lines of the tempdiffs
#we have to manually add points to the line through annotate to show the threshold temps and peak brooding for each pop
ggplot(dddf)+
geom_line(aes(x=Date,y=cumsum(dddf$oystempdiff)),color="orange",size=2)+
geom_line(aes(x=Date,y=cumsum(dddf$fidtempdiff)),color="purple",size=2)+
geom_line(aes(x=Date,y=cumsum(dddf$mantempdif)),color="red",size=2)+
annotate("point",x=as.Date("2014-06-03",'%Y-%m-%d'),y=133,size=5,color='red',pch=15)+
annotate("point",x=as.Date("2014-05-14",'%Y-%m-%d'),y=143,size=5,color='red',pch=15)+
annotate("point",x=as.Date("2014-06-08",'%Y-%m-%d'),y=113,size=5,color='red',pch=15)+
annotate("point",x=as.Date("2014-08-08",'%Y-%m-%d'),y=460,size=10,color='blue',pch=13)+
annotate("point",x=as.Date("2014-08-06",'%Y-%m-%d'),y=383,size=10,color='blue',pch=13)+
annotate("point",x=as.Date("2014-07-10",'%Y-%m-%d'),y=520,size=10,color='blue',pch=13)+
annotate("point",x=as.Date("2014-08-08",'%Y-%m-%d'),y=453.021,size=10,color='purple',pch=13)+
annotate("point",x=as.Date("2014-06-25",'%Y-%m-%d'),y=175.322,size=10,color='purple',pch=13)+
annotate("point",x=as.Date("2014-07-10",'%Y-%m-%d'),y=512.999,size=10,color='purple',pch=13)+
annotate("point",x=as.Date("2014-07-11",'%Y-%m-%d'),y=307.894,size=10,color='orange',pch=13)+
annotate("point",x=as.Date("2014-08-06",'%Y-%m-%d'),y=377.561,size=10,color='orange',pch=13)+
annotate("point",x=as.Date("2014-06-19",'%Y-%m-%d'),y=354.156,size=10,color='orange',pch=13)+
theme_bw()+
labs(title="Degree Days compared between Sites and Populations",x="Date",y="Cumulative Degrees over 8 C Minimum")

#each red square represents the date when the threshold 12.5 C spawning temp was reached
#the orange, purple, and red lines are Oyster Bay, Fidalgo, and Manchester Sites respectfull
#the orange, blue, and purple crosshairs are peak brooding for Oyster Bay, Dabob, and Fidalgo pops at each site respectfully
#

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

11 4 2014 Brooder Proportion Stats with Interaction Graph

reproanova.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(ggplot2)
## Loading required package: ggplot2
require(plyr)
## Loading required package: plyr
#Loads required plyr package and a ggplot2 package for plotting
reproaov<-aov(repro4$Brooders~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4)
summary(reproaov)
##                         Df Sum Sq Mean Sq F value  Pr(>F)    
## repro4$Site 2 138 69.2 12.60 1.1e-05 ***
## repro4$Pop 2 99 49.6 9.03 0.00023 ***
## repro4$Site:repro4$Pop 4 31 7.7 1.41 0.23609
## Residuals 117 642 5.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
SitevPopTukey<-TukeyHSD(reproaov)
print(SitevPopTukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = repro4$Brooders ~ repro4$Site + repro4$Pop + repro4$Site:repro4$Pop, data = repro4)
##
## $`repro4$Site`
## diff lwr upr p adj
## Manchester-Fidalgo -0.8571 -2.0710 0.3567 0.2186
## Oyster Bay-Fidalgo 1.6667 0.4529 2.8805 0.0041
## Oyster Bay-Manchester 2.5238 1.3100 3.7376 0.0000
##
## $`repro4$Pop`
## diff lwr upr p adj
## N-H -0.04762 -1.2614 1.166 0.9952
## S-H 1.85714 0.6433 3.071 0.0012
## S-N 1.90476 0.6910 3.119 0.0009
##
## $`repro4$Site:repro4$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H -7.143e-02 -2.87058 2.7277 1.0000
## Oyster Bay:H-Fidalgo:H 1.286e+00 -1.51344 4.0849 0.8749
## Fidalgo:N-Fidalgo:H -4.330e-15 -2.79915 2.7992 1.0000
## Manchester:N-Fidalgo:H -5.000e-01 -3.29915 2.2992 0.9997
## Oyster Bay:N-Fidalgo:H 1.571e+00 -1.22773 4.3706 0.6987
## Fidalgo:S-Fidalgo:H 2.214e+00 -0.58487 5.0134 0.2427
## Manchester:S-Fidalgo:H 2.143e-01 -2.58487 3.0134 1.0000
## Oyster Bay:S-Fidalgo:H 4.357e+00 1.55799 7.1563 0.0001
## Oyster Bay:H-Manchester:H 1.357e+00 -1.44201 4.1563 0.8379
## Fidalgo:N-Manchester:H 7.143e-02 -2.72773 2.8706 1.0000
## Manchester:N-Manchester:H -4.286e-01 -3.22773 2.3706 0.9999
## Oyster Bay:N-Manchester:H 1.643e+00 -1.15630 4.4420 0.6456
## Fidalgo:S-Manchester:H 2.286e+00 -0.51344 5.0849 0.2061
## Manchester:S-Manchester:H 2.857e-01 -2.51344 3.0849 1.0000
## Oyster Bay:S-Manchester:H 4.429e+00 1.62942 7.2277 0.0001
## Fidalgo:N-Oyster Bay:H -1.286e+00 -4.08487 1.5134 0.8749
## Manchester:N-Oyster Bay:H -1.786e+00 -4.58487 1.0134 0.5353
## Oyster Bay:N-Oyster Bay:H 2.857e-01 -2.51344 3.0849 1.0000
## Fidalgo:S-Oyster Bay:H 9.286e-01 -1.87058 3.7277 0.9801
## Manchester:S-Oyster Bay:H -1.071e+00 -3.87058 1.7277 0.9529
## Oyster Bay:S-Oyster Bay:H 3.071e+00 0.27227 5.8706 0.0203
## Manchester:N-Fidalgo:N -5.000e-01 -3.29915 2.2992 0.9997
## Oyster Bay:N-Fidalgo:N 1.571e+00 -1.22773 4.3706 0.6987
## Fidalgo:S-Fidalgo:N 2.214e+00 -0.58487 5.0134 0.2427
## Manchester:S-Fidalgo:N 2.143e-01 -2.58487 3.0134 1.0000
## Oyster Bay:S-Fidalgo:N 4.357e+00 1.55799 7.1563 0.0001
## Oyster Bay:N-Manchester:N 2.071e+00 -0.72773 4.8706 0.3279
## Fidalgo:S-Manchester:N 2.714e+00 -0.08487 5.5134 0.0649
## Manchester:S-Manchester:N 7.143e-01 -2.08487 3.5134 0.9965
## Oyster Bay:S-Manchester:N 4.857e+00 2.05799 7.6563 0.0000
## Fidalgo:S-Oyster Bay:N 6.429e-01 -2.15630 3.4420 0.9983
## Manchester:S-Oyster Bay:N -1.357e+00 -4.15630 1.4420 0.8379
## Oyster Bay:S-Oyster Bay:N 2.786e+00 -0.01344 5.5849 0.0521
## Manchester:S-Fidalgo:S -2.000e+00 -4.79915 0.7992 0.3760
## Oyster Bay:S-Fidalgo:S 2.143e+00 -0.65630 4.9420 0.2834
## Oyster Bay:S-Manchester:S 4.143e+00 1.34370 6.9420 0.0003
#Standard ANOVA and TukeyHSD on non transformed data. Finds huge difference between pops and sites but heavily skewed and non normaly distributed.
repro4$arcsinbrooders<-asin(sign(repro4$Brooders)*sqrt(abs(repro4$Brooders)))
## Warning: NaNs produced
repro4$arcsinbrooders<-replace(repro4$arcsinbrooders,is.na(repro4$arcsinbrooders),0)
#For fun, arc sine transformed brooder data. This is essentially meaningless in the long run.
reproaov2<-aov(repro4$arcsinbrooders~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4)
summary(reproaov2)
##                         Df Sum Sq Mean Sq F value Pr(>F)
## repro4$Site 2 0.3 0.137 0.44 0.64
## repro4$Pop 2 1.4 0.725 2.35 0.10
## repro4$Site:repro4$Pop 4 2.0 0.490 1.59 0.18
## Residuals 117 36.1 0.309
arcsinbroodertukey<-TukeyHSD(reproaov2)
print(arcsinbroodertukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = repro4$arcsinbrooders ~ repro4$Site + repro4$Pop + repro4$Site:repro4$Pop, data = repro4)
##
## $`repro4$Site`
## diff lwr upr p adj
## Manchester-Fidalgo 0.1122 -0.1757 0.4001 0.6255
## Oyster Bay-Fidalgo 0.0374 -0.2505 0.3253 0.9489
## Oyster Bay-Manchester -0.0748 -0.3627 0.2131 0.8112
##
## $`repro4$Pop`
## diff lwr upr p adj
## N-H -0.1496 -0.4375 0.13827 0.4358
## S-H -0.2618 -0.5497 0.02607 0.0827
## S-N -0.1122 -0.4001 0.17567 0.6255
##
## $`repro4$Site:repro4$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H 4.488e-01 -0.2151 1.1127 0.4539
## Oyster Bay:H-Fidalgo:H 3.366e-01 -0.3273 1.0005 0.8016
## Fidalgo:N-Fidalgo:H 2.244e-01 -0.4395 0.8883 0.9776
## Manchester:N-Fidalgo:H 1.388e-15 -0.6639 0.6639 1.0000
## Oyster Bay:N-Fidalgo:H 1.122e-01 -0.5517 0.7761 0.9998
## Fidalgo:S-Fidalgo:H 2.345e-15 -0.6639 0.6639 1.0000
## Manchester:S-Fidalgo:H 1.122e-01 -0.5517 0.7761 0.9998
## Oyster Bay:S-Fidalgo:H -1.122e-01 -0.7761 0.5517 0.9998
## Oyster Bay:H-Manchester:H -1.122e-01 -0.7761 0.5517 0.9998
## Fidalgo:N-Manchester:H -2.244e-01 -0.8883 0.4395 0.9776
## Manchester:N-Manchester:H -4.488e-01 -1.1127 0.2151 0.4539
## Oyster Bay:N-Manchester:H -3.366e-01 -1.0005 0.3273 0.8016
## Fidalgo:S-Manchester:H -4.488e-01 -1.1127 0.2151 0.4539
## Manchester:S-Manchester:H -3.366e-01 -1.0005 0.3273 0.8016
## Oyster Bay:S-Manchester:H -5.610e-01 -1.2249 0.1029 0.1699
## Fidalgo:N-Oyster Bay:H -1.122e-01 -0.7761 0.5517 0.9998
## Manchester:N-Oyster Bay:H -3.366e-01 -1.0005 0.3273 0.8016
## Oyster Bay:N-Oyster Bay:H -2.244e-01 -0.8883 0.4395 0.9776
## Fidalgo:S-Oyster Bay:H -3.366e-01 -1.0005 0.3273 0.8016
## Manchester:S-Oyster Bay:H -2.244e-01 -0.8883 0.4395 0.9776
## Oyster Bay:S-Oyster Bay:H -4.488e-01 -1.1127 0.2151 0.4539
## Manchester:N-Fidalgo:N -2.244e-01 -0.8883 0.4395 0.9776
## Oyster Bay:N-Fidalgo:N -1.122e-01 -0.7761 0.5517 0.9998
## Fidalgo:S-Fidalgo:N -2.244e-01 -0.8883 0.4395 0.9776
## Manchester:S-Fidalgo:N -1.122e-01 -0.7761 0.5517 0.9998
## Oyster Bay:S-Fidalgo:N -3.366e-01 -1.0005 0.3273 0.8016
## Oyster Bay:N-Manchester:N 1.122e-01 -0.5517 0.7761 0.9998
## Fidalgo:S-Manchester:N 9.576e-16 -0.6639 0.6639 1.0000
## Manchester:S-Manchester:N 1.122e-01 -0.5517 0.7761 0.9998
## Oyster Bay:S-Manchester:N -1.122e-01 -0.7761 0.5517 0.9998
## Fidalgo:S-Oyster Bay:N -1.122e-01 -0.7761 0.5517 0.9998
## Manchester:S-Oyster Bay:N 6.384e-16 -0.6639 0.6639 1.0000
## Oyster Bay:S-Oyster Bay:N -2.244e-01 -0.8883 0.4395 0.9776
## Manchester:S-Fidalgo:S 1.122e-01 -0.5517 0.7761 0.9998
## Oyster Bay:S-Fidalgo:S -1.122e-01 -0.7761 0.5517 0.9998
## Oyster Bay:S-Manchester:S -2.244e-01 -0.8883 0.4395 0.9776
#Makes ANOVA based on arcsine transform of brooders. Finds no differences which is also skewed.
repro4$prop<-repro4$Brooders/repro4$Gaping
#creates individual proportion for each sample date
repro4$arcsinprop<-asin(sign(repro4$prop)*sqrt(abs(repro4$prop)))
repro4$arcsinprop<-replace(repro4$arcsinprop,is.na(repro4$arcsinprop),0)
#arcsine transforms individual proportion data to normalize for use in ANOVA and TukeyHSD.
reproaov3<-aov(repro4$arcsinprop~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4)
summary(reproaov3)
##                         Df Sum Sq Mean Sq F value  Pr(>F)    
## repro4$Site 2 0.258 0.1290 11.33 3.2e-05 ***
## repro4$Pop 2 0.127 0.0636 5.59 0.0048 **
## repro4$Site:repro4$Pop 4 0.029 0.0073 0.64 0.6335
## Residuals 117 1.332 0.0114
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(reproaov3)
##                         Df Sum Sq Mean Sq F value  Pr(>F)    
## repro4$Site 2 0.258 0.1290 11.33 3.2e-05 ***
## repro4$Pop 2 0.127 0.0636 5.59 0.0048 **
## repro4$Site:repro4$Pop 4 0.029 0.0073 0.64 0.6335
## Residuals 117 1.332 0.0114
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
arcsinproptukey<-TukeyHSD(reproaov3)
print(arcsinproptukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = repro4$arcsinprop ~ repro4$Site + repro4$Pop + repro4$Site:repro4$Pop, data = repro4)
##
## $`repro4$Site`
## diff lwr upr p adj
## Manchester-Fidalgo -0.03381 -0.08907 0.02146 0.3178
## Oyster Bay-Fidalgo 0.07450 0.01923 0.12976 0.0050
## Oyster Bay-Manchester 0.10830 0.05304 0.16357 0.0000
##
## $`repro4$Pop`
## diff lwr upr p adj
## N-H -0.01821 -0.073473 0.03705 0.7147
## S-H 0.05645 0.001185 0.11171 0.0441
## S-N 0.07466 0.019394 0.12992 0.0049
##
## $`repro4$Site:repro4$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H 0.004467 -0.122977 0.13191 1.0000
## Oyster Bay:H-Fidalgo:H 0.071372 -0.056071 0.19882 0.7015
## Fidalgo:N-Fidalgo:H -0.013294 -0.140738 0.11415 1.0000
## Manchester:N-Fidalgo:H -0.045447 -0.172890 0.08200 0.9689
## Oyster Bay:N-Fidalgo:H 0.079952 -0.047491 0.20740 0.5583
## Fidalgo:S-Fidalgo:H 0.086684 -0.040759 0.21413 0.4452
## Manchester:S-Fidalgo:H 0.012947 -0.114497 0.14039 1.0000
## Oyster Bay:S-Fidalgo:H 0.145553 0.018110 0.27300 0.0130
## Oyster Bay:H-Manchester:H 0.066905 -0.060538 0.19435 0.7696
## Fidalgo:N-Manchester:H -0.017761 -0.145204 0.10968 1.0000
## Manchester:N-Manchester:H -0.049914 -0.177357 0.07753 0.9463
## Oyster Bay:N-Manchester:H 0.075485 -0.051958 0.20293 0.6341
## Fidalgo:S-Manchester:H 0.082217 -0.045226 0.20966 0.5198
## Manchester:S-Manchester:H 0.008480 -0.118963 0.13592 1.0000
## Oyster Bay:S-Manchester:H 0.141086 0.013643 0.26853 0.0184
## Fidalgo:N-Oyster Bay:H -0.084667 -0.212110 0.04278 0.4786
## Manchester:N-Oyster Bay:H -0.116819 -0.244263 0.01062 0.1000
## Oyster Bay:N-Oyster Bay:H 0.008580 -0.118864 0.13602 1.0000
## Fidalgo:S-Oyster Bay:H 0.015312 -0.112131 0.14276 1.0000
## Manchester:S-Oyster Bay:H -0.058426 -0.185869 0.06902 0.8761
## Oyster Bay:S-Oyster Bay:H 0.074181 -0.053262 0.20162 0.6558
## Manchester:N-Fidalgo:N -0.032153 -0.159596 0.09529 0.9968
## Oyster Bay:N-Fidalgo:N 0.093246 -0.034197 0.22069 0.3433
## Fidalgo:S-Fidalgo:N 0.099979 -0.027465 0.22742 0.2528
## Manchester:S-Fidalgo:N 0.026241 -0.101202 0.15368 0.9992
## Oyster Bay:S-Fidalgo:N 0.158848 0.031404 0.28629 0.0043
## Oyster Bay:N-Manchester:N 0.125399 -0.002044 0.25284 0.0575
## Fidalgo:S-Manchester:N 0.132131 0.004688 0.25957 0.0359
## Manchester:S-Manchester:N 0.058394 -0.069050 0.18584 0.8764
## Oyster Bay:S-Manchester:N 0.191000 0.063557 0.31844 0.0002
## Fidalgo:S-Oyster Bay:N 0.006732 -0.120711 0.13418 1.0000
## Manchester:S-Oyster Bay:N -0.067005 -0.194449 0.06044 0.7681
## Oyster Bay:S-Oyster Bay:N 0.065601 -0.061842 0.19304 0.7881
## Manchester:S-Fidalgo:S -0.073738 -0.201181 0.05371 0.6631
## Oyster Bay:S-Fidalgo:S 0.058869 -0.068574 0.18631 0.8714
## Oyster Bay:S-Manchester:S 0.132607 0.005163 0.26005 0.0347
#ANOVA and TukeyHSD on Arcsine transformed proportions conservatively finds significant differences between pops and sites. More trust worthy due to normality.
Gapingsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Gaping,na.rm=T))
#Summarises Gaping data for each pop at each site
Broodsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Brooders,na.rm=T))
#Summarises Brooder data for each pop at each site
BroodGapingSum<-merge(Gapingsum,Broodsum,by=c("Site","Pop"))
BroodGapingSum<-rename(BroodGapingSum, c("Site"="Site","Pop"="Pop","sum.x"="Gaping","sum.y"="Brooder"))
BroodGapingSum$prop<-BroodGapingSum$Brooder/BroodGapingSum$Gaping
print(BroodGapingSum)
##         Site Pop Gaping Brooder     prop
## 1 Fidalgo H 814 8 0.009828
## 2 Fidalgo N 813 8 0.009840
## 3 Fidalgo S 921 39 0.042345
## 4 Manchester H 658 7 0.010638
## 5 Manchester N 631 1 0.001585
## 6 Manchester S 699 11 0.015737
## 7 Oyster Bay H 931 26 0.027927
## 8 Oyster Bay N 769 30 0.039012
## 9 Oyster Bay S 883 69 0.078143
#Creates clean Data frame for Summarized data as well as creating raw proportion data from summaries
BroodGapingSum$ArcSine<-asin(sign(BroodGapingSum$prop)*sqrt(abs(BroodGapingSum$prop)))
#Arcsine transforms raw proportions but is not useful.
arcaov<-aov(BroodGapingSum$ArcSine~BroodGapingSum$Site+BroodGapingSum$Pop+BroodGapingSum$Site:BroodGapingSum$Pop,BroodGapingSum)
summary(arcaov)
##                                        Df  Sum Sq Mean Sq
## BroodGapingSum$Site 2 0.02485 0.01242
## BroodGapingSum$Pop 2 0.01544 0.00772
## BroodGapingSum$Site:BroodGapingSum$Pop 4 0.00344 0.00086
arcTukey<-TukeyHSD(arcaov)
## Warning: NaNs produced
## Warning: NaNs produced
## Warning: NaNs produced
print(arcTukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = BroodGapingSum$ArcSine ~ BroodGapingSum$Site + BroodGapingSum$Pop + BroodGapingSum$Site:BroodGapingSum$Pop, data = BroodGapingSum)
##
## $`BroodGapingSum$Site`
## diff lwr upr p adj
## Manchester-Fidalgo -0.04567 NaN NaN NaN
## Oyster Bay-Fidalgo 0.08137 NaN NaN NaN
## Oyster Bay-Manchester 0.12704 NaN NaN NaN
##
## $`BroodGapingSum$Pop`
## diff lwr upr p adj
## N-H -0.01084 NaN NaN NaN
## S-H 0.08194 NaN NaN NaN
## S-N 0.09278 NaN NaN NaN
##
## $`BroodGapingSum$Site:BroodGapingSum$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H 4.026e-03 NaN NaN NaN
## Oyster Bay:H-Fidalgo:H 6.860e-02 NaN NaN NaN
## Fidalgo:N-Fidalgo:H 6.125e-05 NaN NaN NaN
## Manchester:N-Fidalgo:H -5.948e-02 NaN NaN NaN
## Oyster Bay:N-Fidalgo:H 9.952e-02 NaN NaN NaN
## Fidalgo:S-Fidalgo:H 1.080e-01 NaN NaN NaN
## Manchester:S-Fidalgo:H 2.648e-02 NaN NaN NaN
## Oyster Bay:S-Fidalgo:H 1.840e-01 NaN NaN NaN
## Oyster Bay:H-Manchester:H 6.458e-02 NaN NaN NaN
## Fidalgo:N-Manchester:H -3.965e-03 NaN NaN NaN
## Manchester:N-Manchester:H -6.351e-02 NaN NaN NaN
## Oyster Bay:N-Manchester:H 9.550e-02 NaN NaN NaN
## Fidalgo:S-Manchester:H 1.039e-01 NaN NaN NaN
## Manchester:S-Manchester:H 2.245e-02 NaN NaN NaN
## Oyster Bay:S-Manchester:H 1.800e-01 NaN NaN NaN
## Fidalgo:N-Oyster Bay:H -6.854e-02 NaN NaN NaN
## Manchester:N-Oyster Bay:H -1.281e-01 NaN NaN NaN
## Oyster Bay:N-Oyster Bay:H 3.092e-02 NaN NaN NaN
## Fidalgo:S-Oyster Bay:H 3.936e-02 NaN NaN NaN
## Manchester:S-Oyster Bay:H -4.212e-02 NaN NaN NaN
## Oyster Bay:S-Oyster Bay:H 1.154e-01 NaN NaN NaN
## Manchester:N-Fidalgo:N -5.954e-02 NaN NaN NaN
## Oyster Bay:N-Fidalgo:N 9.946e-02 NaN NaN NaN
## Fidalgo:S-Fidalgo:N 1.079e-01 NaN NaN NaN
## Manchester:S-Fidalgo:N 2.642e-02 NaN NaN NaN
## Oyster Bay:S-Fidalgo:N 1.840e-01 NaN NaN NaN
## Oyster Bay:N-Manchester:N 1.590e-01 NaN NaN NaN
## Fidalgo:S-Manchester:N 1.674e-01 NaN NaN NaN
## Manchester:S-Manchester:N 8.596e-02 NaN NaN NaN
## Oyster Bay:S-Manchester:N 2.435e-01 NaN NaN NaN
## Fidalgo:S-Oyster Bay:N 8.439e-03 NaN NaN NaN
## Manchester:S-Oyster Bay:N -7.304e-02 NaN NaN NaN
## Oyster Bay:S-Oyster Bay:N 8.449e-02 NaN NaN NaN
## Manchester:S-Fidalgo:S -8.148e-02 NaN NaN NaN
## Oyster Bay:S-Fidalgo:S 7.605e-02 NaN NaN NaN
## Oyster Bay:S-Manchester:S 1.575e-01 NaN NaN NaN
#Arcsine transform on raw proportions fails due to lack of replicates
Proptest<-prop.test(BroodGapingSum$Brooder,BroodGapingSum$Gaping, conf.level=0.95)
print(Proptest)
## 
## 9-sample test for equality of proportions without continuity
## correction
##
## data: BroodGapingSum$Brooder out of BroodGapingSum$Gaping
## X-squared = 139.2, df = 8, p-value < 2.2e-16
## alternative hypothesis: two.sided
## sample estimates:
## prop 1 prop 2 prop 3 prop 4 prop 5 prop 6 prop 7 prop 8
## 0.009828 0.009840 0.042345 0.010638 0.001585 0.015737 0.027927 0.039012
## prop 9
## 0.078143
#Proportion test with confidence levels. Doesn't have meaning.
ggplot(data=BroodGapingSum,aes(x=Site, y=prop, group=Pop, col=Pop))+
geom_line(size=2)+geom_point(size=6)+
scale_color_manual(name="Population",
labels=c("Dabob","Fidalgo","Oyster Bay"),
values=c("blue","purple","orange"))+
labs(title="Raw Proportion of Brooders\nSite by Population",
x="Site",y="Raw Proportion of Brooders")+
theme_bw()+
theme(axis.text.x=element_text(color=c("purple","red","orange"), size=20),
axis.text.y=element_text(color="black",size=15),
axis.title.x=element_text(color="black",size=25),
axis.title.y=element_text(color="black",size=25),
plot.title=element_text(color="forestgreen",size=35),
legend.justification=c(0,1),
legend.position=c(0,1))

#Graph uses raw proportions of brooders to gaping animals produced at each site.
#ANOVA and Tukey test on proportions uses arcsin transformed data for normality
#ANOVA/Tukey Find that the Oyster Bay site is significantly Different from the other two sites
#ANOVA/Tukey Find that the Oyster Bay Pop is significantly Different from the other two pops.
#Individual interactions find that the Oyster Bay pop at Oyster Bay site is significantly
#different than all almost all other populations at all other sites including itself at Manchester
#but not significantly different than the other two populations at Oyster Bay site

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

11 3 2014 Brooder Proportion Stats Tests

reproanova.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(ggplot2)
## Loading required package: ggplot2
require(plyr)
## Loading required package: plyr
reproftable<-ftable(repro4$Date, repro4$Site, repro4$Pop, repro4$Brooders, exclude=c(NA, NaN,0))
summary(reproftable)
##        V1               V2               V3               V4        
## Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000 Median :0.0000 Median :0.0000
## Mean :0.0503 Mean :0.0265 Mean :0.0238 Mean :0.0053
## 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000
## V5 V6 V7 V8
## Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000 Median :0.0000 Median :0.0000
## Mean :0.0079 Mean :0.0079 Mean :0.0053 Mean :0.0053
## 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000
## V9 V10 V11
## Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000 Median :0.0000
## Mean :0.0026 Mean :0.0053 Mean :0.0079
## 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
reproaov<-aov(repro4$Brooders~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4)
summary(reproaov)
##                         Df Sum Sq Mean Sq F value  Pr(>F)    
## repro4$Site 2 138 69.2 12.60 1.1e-05 ***
## repro4$Pop 2 99 49.6 9.03 0.00023 ***
## repro4$Site:repro4$Pop 4 31 7.7 1.41 0.23609
## Residuals 117 642 5.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
SitevPopTukey<-TukeyHSD(reproaov)
print(SitevPopTukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = repro4$Brooders ~ repro4$Site + repro4$Pop + repro4$Site:repro4$Pop, data = repro4)
##
## $`repro4$Site`
## diff lwr upr p adj
## Manchester-Fidalgo -0.8571 -2.0710 0.3567 0.2186
## Oyster Bay-Fidalgo 1.6667 0.4529 2.8805 0.0041
## Oyster Bay-Manchester 2.5238 1.3100 3.7376 0.0000
##
## $`repro4$Pop`
## diff lwr upr p adj
## N-H -0.04762 -1.2614 1.166 0.9952
## S-H 1.85714 0.6433 3.071 0.0012
## S-N 1.90476 0.6910 3.119 0.0009
##
## $`repro4$Site:repro4$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H -7.143e-02 -2.87058 2.7277 1.0000
## Oyster Bay:H-Fidalgo:H 1.286e+00 -1.51344 4.0849 0.8749
## Fidalgo:N-Fidalgo:H -4.330e-15 -2.79915 2.7992 1.0000
## Manchester:N-Fidalgo:H -5.000e-01 -3.29915 2.2992 0.9997
## Oyster Bay:N-Fidalgo:H 1.571e+00 -1.22773 4.3706 0.6987
## Fidalgo:S-Fidalgo:H 2.214e+00 -0.58487 5.0134 0.2427
## Manchester:S-Fidalgo:H 2.143e-01 -2.58487 3.0134 1.0000
## Oyster Bay:S-Fidalgo:H 4.357e+00 1.55799 7.1563 0.0001
## Oyster Bay:H-Manchester:H 1.357e+00 -1.44201 4.1563 0.8379
## Fidalgo:N-Manchester:H 7.143e-02 -2.72773 2.8706 1.0000
## Manchester:N-Manchester:H -4.286e-01 -3.22773 2.3706 0.9999
## Oyster Bay:N-Manchester:H 1.643e+00 -1.15630 4.4420 0.6456
## Fidalgo:S-Manchester:H 2.286e+00 -0.51344 5.0849 0.2061
## Manchester:S-Manchester:H 2.857e-01 -2.51344 3.0849 1.0000
## Oyster Bay:S-Manchester:H 4.429e+00 1.62942 7.2277 0.0001
## Fidalgo:N-Oyster Bay:H -1.286e+00 -4.08487 1.5134 0.8749
## Manchester:N-Oyster Bay:H -1.786e+00 -4.58487 1.0134 0.5353
## Oyster Bay:N-Oyster Bay:H 2.857e-01 -2.51344 3.0849 1.0000
## Fidalgo:S-Oyster Bay:H 9.286e-01 -1.87058 3.7277 0.9801
## Manchester:S-Oyster Bay:H -1.071e+00 -3.87058 1.7277 0.9529
## Oyster Bay:S-Oyster Bay:H 3.071e+00 0.27227 5.8706 0.0203
## Manchester:N-Fidalgo:N -5.000e-01 -3.29915 2.2992 0.9997
## Oyster Bay:N-Fidalgo:N 1.571e+00 -1.22773 4.3706 0.6987
## Fidalgo:S-Fidalgo:N 2.214e+00 -0.58487 5.0134 0.2427
## Manchester:S-Fidalgo:N 2.143e-01 -2.58487 3.0134 1.0000
## Oyster Bay:S-Fidalgo:N 4.357e+00 1.55799 7.1563 0.0001
## Oyster Bay:N-Manchester:N 2.071e+00 -0.72773 4.8706 0.3279
## Fidalgo:S-Manchester:N 2.714e+00 -0.08487 5.5134 0.0649
## Manchester:S-Manchester:N 7.143e-01 -2.08487 3.5134 0.9965
## Oyster Bay:S-Manchester:N 4.857e+00 2.05799 7.6563 0.0000
## Fidalgo:S-Oyster Bay:N 6.429e-01 -2.15630 3.4420 0.9983
## Manchester:S-Oyster Bay:N -1.357e+00 -4.15630 1.4420 0.8379
## Oyster Bay:S-Oyster Bay:N 2.786e+00 -0.01344 5.5849 0.0521
## Manchester:S-Fidalgo:S -2.000e+00 -4.79915 0.7992 0.3760
## Oyster Bay:S-Fidalgo:S 2.143e+00 -0.65630 4.9420 0.2834
## Oyster Bay:S-Manchester:S 4.143e+00 1.34370 6.9420 0.0003
Gapingsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Gaping,na.rm=T))
Broodsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Brooders,na.rm=T))
BroodGapingSum<-merge(Gapingsum,Broodsum,by=c("Site","Pop"))
BroodGapingSum<-rename(BroodGapingSum, c("Site"="Site","Pop"="Pop","sum.x"="Gaping","sum.y"="Brooder"))
BroodGapingSum$prop<-BroodGapingSum$Brooder/BroodGapingSum$Gaping
print(BroodGapingSum)
##         Site Pop Gaping Brooder     prop
## 1 Fidalgo H 814 8 0.009828
## 2 Fidalgo N 813 8 0.009840
## 3 Fidalgo S 921 39 0.042345
## 4 Manchester H 658 7 0.010638
## 5 Manchester N 631 1 0.001585
## 6 Manchester S 699 11 0.015737
## 7 Oyster Bay H 931 26 0.027927
## 8 Oyster Bay N 769 30 0.039012
## 9 Oyster Bay S 883 69 0.078143
propaov<-aov(BroodGapingSum$prop~BroodGapingSum$Site+BroodGapingSum$Pop+BroodGapingSum$Site:BroodGapingSum$Pop,BroodGapingSum)
summary(propaov)
##                                        Df   Sum Sq  Mean Sq
## BroodGapingSum$Site 2 0.002420 0.001210
## BroodGapingSum$Pop 2 0.001675 0.000838
## BroodGapingSum$Site:BroodGapingSum$Pop 4 0.000524 0.000131
PropTukey<-TukeyHSD(propaov)
## Warning: NaNs produced
## Warning: NaNs produced
## Warning: NaNs produced
print(PropTukey)
##   Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = BroodGapingSum$prop ~ BroodGapingSum$Site + BroodGapingSum$Pop + BroodGapingSum$Site:BroodGapingSum$Pop, data = BroodGapingSum)
##
## $`BroodGapingSum$Site`
## diff lwr upr p adj
## Manchester-Fidalgo -0.01135 NaN NaN NaN
## Oyster Bay-Fidalgo 0.02769 NaN NaN NaN
## Oyster Bay-Manchester 0.03904 NaN NaN NaN
##
## $`BroodGapingSum$Pop`
## diff lwr upr p adj
## N-H 0.0006811 NaN NaN NaN
## S-H 0.0292772 NaN NaN NaN
## S-N 0.0285961 NaN NaN NaN
##
## $`BroodGapingSum$Site:BroodGapingSum$Pop`
## diff lwr upr p adj
## Manchester:H-Fidalgo:H 8.103e-04 NaN NaN NaN
## Oyster Bay:H-Fidalgo:H 1.810e-02 NaN NaN NaN
## Fidalgo:N-Fidalgo:H 1.209e-05 NaN NaN NaN
## Manchester:N-Fidalgo:H -8.243e-03 NaN NaN NaN
## Oyster Bay:N-Fidalgo:H 2.918e-02 NaN NaN NaN
## Fidalgo:S-Fidalgo:H 3.252e-02 NaN NaN NaN
## Manchester:S-Fidalgo:H 5.909e-03 NaN NaN NaN
## Oyster Bay:S-Fidalgo:H 6.831e-02 NaN NaN NaN
## Oyster Bay:H-Manchester:H 1.729e-02 NaN NaN NaN
## Fidalgo:N-Manchester:H -7.982e-04 NaN NaN NaN
## Manchester:N-Manchester:H -9.054e-03 NaN NaN NaN
## Oyster Bay:N-Manchester:H 2.837e-02 NaN NaN NaN
## Fidalgo:S-Manchester:H 3.171e-02 NaN NaN NaN
## Manchester:S-Manchester:H 5.098e-03 NaN NaN NaN
## Oyster Bay:S-Manchester:H 6.750e-02 NaN NaN NaN
## Fidalgo:N-Oyster Bay:H -1.809e-02 NaN NaN NaN
## Manchester:N-Oyster Bay:H -2.634e-02 NaN NaN NaN
## Oyster Bay:N-Oyster Bay:H 1.108e-02 NaN NaN NaN
## Fidalgo:S-Oyster Bay:H 1.442e-02 NaN NaN NaN
## Manchester:S-Oyster Bay:H -1.219e-02 NaN NaN NaN
## Oyster Bay:S-Oyster Bay:H 5.022e-02 NaN NaN NaN
## Manchester:N-Fidalgo:N -8.255e-03 NaN NaN NaN
## Oyster Bay:N-Fidalgo:N 2.917e-02 NaN NaN NaN
## Fidalgo:S-Fidalgo:N 3.251e-02 NaN NaN NaN
## Manchester:S-Fidalgo:N 5.897e-03 NaN NaN NaN
## Oyster Bay:S-Fidalgo:N 6.830e-02 NaN NaN NaN
## Oyster Bay:N-Manchester:N 3.743e-02 NaN NaN NaN
## Fidalgo:S-Manchester:N 4.076e-02 NaN NaN NaN
## Manchester:S-Manchester:N 1.415e-02 NaN NaN NaN
## Oyster Bay:S-Manchester:N 7.656e-02 NaN NaN NaN
## Fidalgo:S-Oyster Bay:N 3.334e-03 NaN NaN NaN
## Manchester:S-Oyster Bay:N -2.327e-02 NaN NaN NaN
## Oyster Bay:S-Oyster Bay:N 3.913e-02 NaN NaN NaN
## Manchester:S-Fidalgo:S -2.661e-02 NaN NaN NaN
## Oyster Bay:S-Fidalgo:S 3.580e-02 NaN NaN NaN
## Oyster Bay:S-Manchester:S 6.241e-02 NaN NaN NaN
Proptest<-prop.test(BroodGapingSum$Brooder,BroodGapingSum$Gaping, conf.level=0.95)
print(Proptest)
## 
## 9-sample test for equality of proportions without continuity
## correction
##
## data: BroodGapingSum$Brooder out of BroodGapingSum$Gaping
## X-squared = 139.2, df = 8, p-value < 2.2e-16
## alternative hypothesis: two.sided
## sample estimates:
## prop 1 prop 2 prop 3 prop 4 prop 5 prop 6 prop 7 prop 8
## 0.009828 0.009840 0.042345 0.010638 0.001585 0.015737 0.027927 0.039012
## prop 9
## 0.078143

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 30 2014 Dual Y Axis Graph (ggplot2) % Brooding vs Temperature Oyster Bay

Here I’m showing how to produce a dual Y axis graph with ggplot2 package in R. If you’ve tried to do this before you know it downright impossible. I found a great work around in the rpubs from a user named Hadley. Below is my code to produce a dual axis bar and line graph. I’m doing this to show the percent of animals brooding at each time point along with the associated temperature at that time point.  Broodperctemp.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(plyr)
## Loading required package: plyr
require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
require(grid)
## Loading required package: grid
require(gtable)
## Loading required package: gtable
grid.newpage()
p1<-ggplot(data=oysbay, aes(x=Date, weight=Percent, colour=Pop, fill=Pop))+
geom_bar(binwidth=10, position=position_dodge())+
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
scale_colour_manual(values=c("blue","purple","orange"),labels=c("Dabob","Fidalgo","Oyster Bay"))+
scale_fill_manual(values=c("blue","purple","orange"),labels=c("Dabob","Fidalgo","Oyster Bay"))+
labs(x="Sample Date", y="Percent Brooding",title="Percent Brooding vs. Temperature")+
theme_bw()+
theme(legend.justification=c(0,1),
legend.position=c(0,1),
plot.title=element_text(size=30,vjust=1),
axis.text.x=element_text(size=20),
axis.text.y=element_text(size=20),
axis.title.x=element_text(size=20),
axis.title.y=element_text(size=20))
oysy1edit<-read.csv("TempData/oysY1fixed.csv")
oysy1edit$Date<-as.Date(oysy1edit$Date, "%m/%d/%Y")
oysmintemp<-ddply(oysy1edit,.(Date),summarise,min_temp=min(Temp,na.rm=T))
oysmintemprep="2014-05-01"& Date<="2014-08-07")
p2<-ggplot()+geom_line(data=oysmintemprep,
aes(x=Date, y=min_temp), color="red")+
geom_hline(yintercept=12.5, color="forestgreen")+
theme_bw() %+replace%
theme(panel.background = element_rect(fill = NA),
panel.grid.major.x=element_blank(),
panel.grid.minor.x=element_blank(),
panel.grid.major.y=element_blank(),
panel.grid.minor.y=element_blank(),
axis.text.y=element_text(size=20,color="red"),
axis.title.y=element_text(size=20))

g1<-ggplot_gtable(ggplot_build(p1))
g2<-ggplot_gtable(ggplot_build(p2))

pp<-c(subset(g1$layout,name=="panel",se=t:r))
g<-gtable_add_grob(g1, g2$grobs[[which(g2$layout$name=="panel")]],pp$t,pp$l,pp$b,pp$l)

ia<-which(g2$layout$name=="axis-l")
ga <- g2$grobs[[ia]]
ax <- ga$children[[2]]
ax$widths <- rev(ax$widths)
ax$grobs <- rev(ax$grobs)
ax$grobs[[1]]$x <- ax$grobs[[1]]$x - unit(1, "npc") + unit(0.15, "cm")
g <- gtable_add_cols(g, g2$widths[g2$layout[ia, ]$l], length(g$widths) - 1)
g <- gtable_add_grob(g, ax, pp$t, length(g$widths) - 1, pp$b)

grid.draw(g)

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

It’s really important to note that I have subset the temperature data for only the daily minimums and  only from the date of the first sampling to the date of the last sampling. If you don’t do this, the temp graph will be fit onto the graph regardless of whether it correlates to the dates on the x axis. My first version was really screwy because of this. Also note that for some reason when using this method you cannot create a legend for the line graph nor can you generate a title for the right hand y axis. It’s not the best but it will make a good looking graph for you if you know these limitations. 

10 29 2014 Growth Rate with Slope and P-Value Calculations

growthratecomparison.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
require(plyr)
## Loading required package: plyr
require(splitstackshape)
## Loading required package: splitstackshape
## Loading required package: data.table
picsize7=read.csv('imagejsizefixed1.csv')
picsize8<-concat.split.multiple(picsize7, "Tray", " ")
mansize<-subset(picsize8, Site %in% c("Manchester","manchester"))
mansize$Date<-as.Date(mansize$Date, "%m/%d/%Y")
ggplot(mansize, aes(Date,Length.mm, group=Tray_1, color=Tray_1))+
geom_point()+geom_smooth(method=lm)+
scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))

mods<-dlply(mansize,.(Tray_1),function(x)lm(Length.mm~Date,data=x))
slope<-function(x)coef(x)[2]
pvalF)'[1]
s1<-ldply(mods,slope)
s2<-ldply(mods,pval)
ds_outman<-join(s1,s2)
## Joining by: Tray_1
names(ds_outman)[3]<-"pvalue"
ds_outman$slab<-sprintf('Slope:%7.5f',ds_outman$Date)
ds_outman$plab<-sprintf('p-value:%7.5f',ds_outman$pvalue)
print(ds_outman)
##   Tray_1    Date    pvalue          slab            plab
## 1 4H 0.03183 8.371e-53 Slope:0.03183 p-value:0.00000
## 2 4N 0.03443 4.414e-34 Slope:0.03443 p-value:0.00000
## 3 4S 0.03942 1.914e-77 Slope:0.03942 p-value:0.00000
mods<-dlply(oyssize,.(Tray_1),function(x)lm(Length.mm~Date,data=x))
slope<-function(x)coef(x)[2]
pvalF)'[1]
s1<-ldply(mods,slope)
s2<-ldply(mods,pval)
ds_outoys<-join(s1,s2)
## Joining by: Tray_1
names(ds_outoys)[3]<-"pvalue"
ds_outoys$slab<-sprintf('Slope:%7.5f',ds_outoys$Date)
ds_outoys$plab<-sprintf('p-value:%7.5f',ds_outoys$pvalue)
print(ds_outoys)
##   Tray_1 Date5/1/2014    pvalue          slab            plab
## 1 1H 1.545 8.119e-68 Slope:1.54481 p-value:0.00000
## 2 1N 2.025 3.019e-92 Slope:2.02485 p-value:0.00000
## 3 1S 1.614 1.270e-27 Slope:1.61403 p-value:0.00000
mods<-dlply(fidsize,.(Tray_1),function(x)lm(Length.mm~Date,data=x))
slope<-function(x)coef(x)[2]
pvalF)'[1]
s1<-ldply(mods,slope)
s2<-ldply(mods,pval)
ds_outfid<-join(s1,s2)
## Joining by: Tray_1
names(ds_outfid)[3]<-"pvalue"
ds_outfid$slab<-sprintf('Slope:%7.5f',ds_outfid$Date)
ds_outfid$plab<-sprintf('p-value:%7.5f',ds_outfid$pvalue)
print(ds_outfid)
##   Tray_1 Date5/2/2014     pvalue           slab            plab
## 1 2H -0.03446 1.450e-114 Slope:-0.03446 p-value:0.00000
## 2 2N -0.32543 5.246e-75 Slope:-0.32543 p-value:0.00000
## 3 2S 1.44133 1.861e-92 Slope:1.44133 p-value:0.00000

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 28 2014 Manchester Year 1 Temperature Update

ManTempConcat.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

library(plyr)
library(ggplot2)
library(scales)
manaugfeb<-read.table('ManAugtoFeb.csv', row.names=1)
#read in data, first change column names and remove data name in excel to make it work
head(manaugfeb)
##          V2    V3    V4
## 1 8/17/2013 10:00 21.28
## 2 8/17/2013 10:15 21.66
## 3 8/17/2013 10:30 21.86
## 4 8/17/2013 10:45 22.14
## 5 8/17/2013 11:00 22.24
## 6 8/17/2013 11:15 22.24
manaugfeb<-rename(manaugfeb, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
manaugfeb$Date<-as.Date(manaugfeb$Date, "%m/%d/%Y")
#tell R that these are dates
tmptst<-ddply(manaugfeb,.(Date),summarise, mean_temp=mean(Temp,na.rm=T))
#creates mean temperature per date using summary statistics and ddply
plot(mean_temp~Date,data=tmptst)

plot of chunk unnamed-chunk-1

manfebmay<-read.table('ManchesterFebtoMay2014.csv', row.names=1)
manmayjun<-read.table('ManchesterMaytoJun14.csv', row.names=1)
manjunjul<-read.table('ManchesterJuntoJul14.csv', row.names=1)
#entered in all other CSVs
manfebmay<-rename(manfebmay, c("V2"="Date",'V3'='Time','V4'='Temp'))
manmayjun<-rename(manmayjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
manjunjul<-rename(manjunjul, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
manfebmay$Date<-as.Date(manfebmay$Date, "%m/%d/%Y")
manmayjun$Date<-as.Date(manmayjun$Date, "%m/%d/%Y")
manjunjul$Date<-as.Date(manjunjul$Date, "%m/%d/%Y")
#Date column as dates
many1<-rbind(manaugfeb,manfebmay,manmayjun,manjunjul)
#concats all temp data

#creates csv for manual editting in excel. Manual editting used to remove artifacts
many1edit<-read.csv("manY1.csv")
#reads in edited CSV to correct for outliers.
manjuloct<-read.table('ManchesterJultoOct2014.csv')
manaugoct<-read.table('ManchesterAugtoOct2014.csv')
#reads in new temp data from jul and aug to october 2014
manjuloct<-rename(manjuloct, c("V2"="Date",'V3'='Time','V4'='Temp'))
manaugoct<-rename(manaugoct, c("V2"="Date",'V3'='Time','V4'='Temp'))
#renames things
manjuloct$Date<-as.Date(manjuloct$Date, "%m/%d/%Y")
manaugoct$Date<-as.Date(manaugoct$Date, "%m/%d/%Y")
manoct<-merge(manjuloct, manaugoct,by=c("Date","Time","Temp"),all=T,sort=F)
manoct$Date<-as.Date(manoct$Date)
many1edit$Date<-as.Date(many1edit$Date)
many1edit2<-merge(many1edit,manoct, by=c("Date","Time","Temp"),all=T,sort=F)
#creates new data frame for all y1 temps
many1edit2$Date<-as.Date(many1edit2$Date)
#Dates as DATES in r

many1v3<-read.csv('many1v3_3.csv')
many1v3$Date<-as.Date(many1v3$Date,"%m/%d/%Y")
manmeantemp<-ddply(many1v3,.(Date),summarise,mean_temp=mean(Temp,na.rm=T))
#creates mean temp file
manmintemp<-ddply(many1v3,.(Date),summarise,min_temp=min(Temp,na.rm=T))
#creates min temp file
manmaxtemp<-ddply(many1v3,.(Date),summarise,max_temp=max(Temp,na.rm=T))
#creates max temp file
manmedtemp<-ddply(many1v3,.(Date),summarise,med_temp=median(Temp,na.rm=T))
#creates med temp file
ggplot(data=manmedtemp, aes(Date, med_temp, group=1))+geom_line(color="Sky Blue",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots median temps
ggplot(data=manmintemp, aes(Date, min_temp, group=1))+geom_line(color="Sky Blue",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots min temps
ggplot()+geom_line(data=manmeantemp, aes(Date,mean_temp, group=1), color="Sky Blue",size=1)+geom_line(data=manmintemp, aes(Date,min_temp,group=1),color="blue",size=1)+geom_line(data=manmaxtemp,aes(Date,max_temp,group=1),color="red",size=1)+geom_abline(intercept=12.5, slope=0,color="red", size=0.5)+labs(x="Date",y="Min|Max|Mean Temperatures(C)")+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots all temps

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 28 2014 Updated Fidalgo Temperatures Year 1

FidalgoTempConcatScript.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

library(plyr)
library(ggplot2)
library(scales)
fidaugfeb<-read.table('FidAugtoFeb.csv', row.names=1)
#read in data, first change column names and remove data name in excel to make it work
head(fidaugfeb)
##          V2    V3    V4
## 1 8/17/2013 9:51 21.38
## 2 8/17/2013 10:06 21.57
## 3 8/17/2013 10:21 21.57
## 4 8/17/2013 10:36 21.76
## 5 8/17/2013 10:51 22.05
## 6 8/17/2013 11:06 22.05
fidaugfeb<-rename(fidaugfeb, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
fidaugfeb$Date<-as.Date(fidaugfeb$Date, "%m/%d/%Y")
#tell R that these are dates
tmptst<-ddply(fidaugfeb,.(Date),summarise, mean_temp=mean(Temp,na.rm=T))
#creates mean temperature per date using summary statistics and ddply
plot(mean_temp~Date,data=tmptst)

fidfebmay<-read.table('FidalgoFebtoMay2014.csv', row.names=1)
fidmayjun<-read.table('FidalgoMaytoJun14.csv', row.names=1)
fidjunjul<-read.table('FidalgoJuntoJul14.csv', row.names=1)
fidjuloct<-read.table('FidalgoJultoOct2014.csv', row.names=1)
fidjunoct<-read.table('FidalgoJuntoOct2014.csv', row.names=1)
#entered in all other CSVs
fidfebmay<-rename(fidfebmay, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidmayjun<-rename(fidmayjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjunjul<-rename(fidjunjul, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjunoct<-rename(fidjunoct, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjuloct<-rename(fidjuloct, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
fidfebmay$Date<-as.Date(fidfebmay$Date, "%m/%d/%Y")
fidmayjun$Date<-as.Date(fidmayjun$Date, "%m/%d/%Y")
fidjunjul$Date<-as.Date(fidjunjul$Date, "%m/%d/%Y")
fidjunoct$Date<-as.Date(fidjunoct$Date, "%m/%d/%Y")
fidjuloct$Date<-as.Date(fidjuloct$Date, "%m/%d/%Y")
#Date column as dates
fidy1<-rbind(fidaugfeb,fidfebmay,fidmayjun,fidjunjul,fidjunoct,fidjuloct)
#concats all temp data

fidy1edit<-read.csv("fidY1.csv")
#reads in edited CSV to correct for outliers.
fidy1edit$Date<-as.Date(fidy1edit$Date, "%m/%d/%Y")
#Dates as DATES in r
fidy1editv2<-rbind(fidy1edit,fidjunoct,fidjuloct)
#adds data for June and July to October to preedited temp.
fidy1editv2$Date<-as.Date(fidy1editv2$Date)
#turns dates into dates in r

fidy1v3<-read.csv("fidy1v3.csv")
#reads in editted temp file
fidy1v3$Date<-as.Date(fidy1v3$Date,"%m/%d/%Y")
#turns dates into DATES in r
fidmeantemp<-ddply(fidy1v3,.(Date),summarise,mean_temp=mean(Temp,na.rm=T))
#creates mean temp file
fidmintemp<-ddply(fidy1v3,.(Date),summarise,min_temp=min(Temp,na.rm=T))
#creates min temp file
fidmaxtemp<-ddply(fidy1v3,.(Date),summarise,max_temp=max(Temp,na.rm=T))
#creates max temp file
fidmedtemp<-ddply(fidy1v3,.(Date),summarise,med_temp=median(Temp,na.rm=T))
#creates med temp file
ggplot(data=fidmedtemp, aes(Date, med_temp, group=1))+geom_line(color="purple",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots median temps
ggplot(data=fidmintemp, aes(Date, min_temp, group=1))+geom_line(color="purple",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots min temps
ggplot()+geom_line(data=fidmeantemp, aes(Date,mean_temp, group=1), color="Purple",size=1)+geom_line(data=fidmintemp, aes(Date,min_temp,group=1),color="Blue",size=1)+geom_line(data=fidmaxtemp,aes(Date,max_temp,group=1),color="Red",size=1)+geom_abline(intercept=12.5, slope=0,color="Red", size=0.5)+labs(x="Date",y="Min|Max|Mean Temperatures(C)")+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#plots all temps

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 24 2014 Manchester Fall Maintenance

Manchester WA

Cloudy, High 50’s/Low 60’s

Participants: Sean Bennett and Jake Heare

Performed a full workup on the trays at Manchester: counted live/dead, imaged for size, collected samples and morts. We then transferred the oysters from the trays to cages. Mortality was slight but still somewhat low. Less than 10 animals per tray on average.

Numbers as follow

4H9-12
Live   52
Dead  6

4S13-16
Live  73
Dead  6

4N1-4
Live   55
Dead   0

4S9-12
Live    57
Dead    1

4H1-4
Live    77
Dead    2

4N9-12
Live     46
Dead    3

4S5-8
Live     66
Dead    0

4H13-16
Live    60
Dead    1

4N13-16
Live    64
Dead   0

4H5-8
Live    60
Dead   6

4S1-4
Live     62
Dead    1

4N5-8
Live    62
Dead    5

10 20 2014 Growth Rate Comparison Graphs

growthratecomparison.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
require(plyr)
## Loading required package: plyr
require(splitstackshape)
## Loading required package: splitstackshape
## Loading required package: data.table
picsize7=read.csv('imagejsizefixed1.csv')
picsize8<-concat.split.multiple(picsize7, "Tray", " ")
mansize<-subset(picsize8, Site %in% c("Manchester","manchester"))
mansize$Date<-as.Date(mansize$Date, "%m/%d/%Y")
ggplot(mansize, aes(Date,Length.mm, group=Tray_1, color=Tray_1))+geom_point()+geom_smooth(method=lm)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 17 2014 fidalgo fall maintenance

Fidalgo bay marina

Windy, low to mid 50s. Cloudy partly rainy.

Participants Jay Dimond, sean Bennett,  jake heare.

Did a full work up on the trays and switched animals from the trays to cages for the winter. Mortality very low, less than 1% for all trays. Collected 50 oysters from each pop for genetic sampling. Images collected for size analysis.

Numbers as follow

2H9-12
Live.   83
Dead.   0

2S5-8
Live.     99
Dead.    0

2N9-12
Live.     96
Dead.     0

2N13-16
Live.     104
Dead     0

2S1-4
Live.     93
Dead.    0

2H1-4
Live.     88
Dead.    0

2N1-4
Live.      99
Dead.     0

2H5-8
Live.      99
Dead.     2

2S9-12
Live.      91
Dead.     0

2N5-8
Live.      100
Dead.      0

2H13-16
Live.      94
Dead.     0

2S13-16
Live.      94
Dead.     0

This is a backup for my primary blogger notebook