-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
executable file
·37 lines (37 loc) · 1.19 KB
/
server.R
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
library(shiny)
library(tidyverse)
library(plotly)
load(".RData")
shinyServer(function(input, output) {
output$plot <- renderPlotly({
obj <- partisympati_valkrets %>%
filter(Valkrets %in% input$valkrets) %>% filter(Parti %in% input$parti) %>%
ggplot(aes(x=Månad,
y=Stöd,
ymin=Undre,
ymax=Övre,
colour=Parti,
group=Parti,
text=paste("Parti: ", Parti,"<br>Mätmånadens början: ", Månad,"<br>Stöd: ", Stöd, " (",Undre," - ",Övre,")", sep="")))+
geom_point()+
geom_ribbon(alpha=0.25)+
geom_line()+
scale_y_continuous(limits=c(0,NA))+
scale_color_manual(
values = c(
"C"="#009933",
"KD"="#231977",
"L"="#6BB7EC",
"MP"="#83CF39",
"M"="#1B49DD",
"S"="#EE2020",
"SD"="#DDDD00",
"V"="#AF0000",
"ÖVR."="gray")
)+
ggtitle(paste("Partisympatier i ",input$valkrets, " med felmarginaler (SCBs PSU)", sep=""))+
labs(y="Stöd (bästa parti) (%)", x="Tid (början av mätmånad)")
obj2 <- obj %>% ggplotly(tooltip = c("text"))
})
}
)