-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
123 lines (91 loc) · 5.24 KB
/
server.R
File metadata and controls
123 lines (91 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# pkgTest <- function(x)
# {
# if (!require(x,character.only = TRUE))
# {
# install.packages(x,dep=TRUE)
# if(!require(x,character.only = TRUE)) stop("Package not found")
# }
# }
# pkgTest("shiny")
# pkgTest("ggplot2")
require("shiny")
require("ggplot2")
#options(warn=-1)
AbBkSCol <- c("springgreen4", "cornflowerblue", "mediumvioletred", "darkorange", "red4", "plum3", "wheat3", "orangered2", "blue4")
Dates<- c('08/05/2013', '18/05/2013', '28/05/2013', '08/06/2013', '18/06/2013', '28/06/2013', '08/07/2013', '18/07/2013', '28/07/2013')
Dates <- strptime(as.character(Dates),"%d/%m/%Y",tz="GMT")
WT.dat <- read.csv("MET_dater.csv", stringsAsFactors=F)
WT.dat$Rtime <- strptime(as.character(WT.dat$Rtime),"%d/%m/%Y %H:%M",tz="GMT")
shinyServer(function(input, output) {
data.set <- reactive({
Seed.Dat <- read.csv("all-Data + MET.csv", stringsAsFactors=FALSE)
Seed.Dat$Sowing <- as.character(Seed.Dat$Sowing)
if(input$Altitz != "All") {
Seed.Dat <- Seed.Dat[Seed.Dat$Altitude == input$Altitz, ]
}
if(input$Yearz != "All") {
Seed.Dat <- Seed.Dat[Seed.Dat$Year == input$Yearz, ]
}
if(input$Treatz != "All") {
Seed.Dat <- Seed.Dat[Seed.Dat$Treatment == input$Treatz, ]
}
if(input$Genoz != "All") {
Seed.Dat <- Seed.Dat[Seed.Dat$Genotype == input$Genoz, ]
}
Seed.Dat <- Seed.Dat
})
output$plot <- renderPlot({
if(input$AltGraph) {
p <- ggplot(data.set(), aes_string(x="Sowing", y=input$yaxis)) + geom_boxplot()
p <- p + aes(color=Sowing) + scale_fill_manual(values = (AbBkSCol)) + facet_wrap(Treatment ~ Genotype)
} else{
p <- ggplot(data.set(), aes_string(x=input$xaxis, y=input$yaxis)) + geom_boxplot()
p <- p + aes_string(color=input$xaxis) + facet_wrap( ~ Sowing, ncol=3) +
theme(strip.text.x = element_text(size=10, angle=0),
strip.text.y = element_text(size=12, face="bold"),
strip.background = element_rect(colour="black", fill="white"))
}
print(p)
})
output$METtemp <- renderPlot({
p <- ggplot(WT.dat, aes(Rtime, Temp)) + xlab('Date') + ylab('Temperature (C)') + xlim(Dates[1], Dates[9])
p <- p + geom_point(alpha=0.1, aes(colour = Temp)) + geom_smooth() + facet_grid(Treatment ~ Altitude) + scale_colour_gradient(low = "blue", high = "red")
if(input$SowingDates) {
p <- p + annotate("text", x = Dates[1], y = 0, label = "1", colour = AbBkSCol[1], size = 4)
p <- p + annotate("text", x = Dates[2], y = 0, label = "2", colour = AbBkSCol[2], size = 4)
p <- p + annotate("text", x = Dates[3], y = 0, label = "3", colour = AbBkSCol[3], size = 4)
p <- p + annotate("text", x = Dates[4], y = 0, label = "4", colour = AbBkSCol[4], size = 4)
p <- p + annotate("text", x = Dates[5], y = 0, label = "5", colour = AbBkSCol[5], size = 4)
p <- p + annotate("text", x = Dates[6], y = 0, label = "6", colour = AbBkSCol[6], size = 4)
p <- p + annotate("text", x = Dates[7], y = 0, label = "7", colour = AbBkSCol[7], size = 4)
p <- p + annotate("text", x = Dates[8], y = 0, label = "8", colour = AbBkSCol[8], size = 4)
p <- p + annotate("text", x = Dates[9], y = 0, label = "9", colour = AbBkSCol[9], size = 4)
}
print(p)
})
output$METmost <- renderPlot({
q <- ggplot(WT.dat, aes(Rtime, Moisture)) + xlab('Date') + ylab('Moisture (W/V') + xlim(Dates[1], Dates[9])
q <- q + geom_point(alpha=0.1, aes(colour = Temp)) + geom_smooth() + facet_grid(Treatment ~ Altitude) + scale_colour_gradient(low = "black", high = "blue")
if(input$SowingDates2) {
q <- q + annotate("text", x = Dates[1], y = 0, label = "1", colour = AbBkSCol[1], size = 4)
q <- q + annotate("text", x = Dates[2], y = 0, label = "2", colour = AbBkSCol[2], size = 4)
q <- q + annotate("text", x = Dates[3], y = 0, label = "3", colour = AbBkSCol[3], size = 4)
q <- q + annotate("text", x = Dates[4], y = 0, label = "4", colour = AbBkSCol[4], size = 4)
q <- q + annotate("text", x = Dates[5], y = 0, label = "5", colour = AbBkSCol[5], size = 4)
q <- q + annotate("text", x = Dates[6], y = 0, label = "6", colour = AbBkSCol[6], size = 4)
q <- q + annotate("text", x = Dates[7], y = 0, label = "7", colour = AbBkSCol[7], size = 4)
q <- q + annotate("text", x = Dates[8], y = 0, label = "8", colour = AbBkSCol[8], size = 4)
q <- q + annotate("text", x = Dates[9], y = 0, label = "9", colour = AbBkSCol[9], size = 4)
}
print(q)
})
# # Generate a summary of the data
# output$summary <- renderPrint({
# summary(data())
# })
#
# # Generate an HTML table view of the data
# output$table <- renderTable({
# data.frame(x=data())
# })
})