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
|
server <- function(input, output){
formulaText <- reactive({
input$country_code
})
output$textoutput <- renderText({
formulaText()
})
output$plotoutput <- renderPlot({
plotdata <- switch (input$country_code,
subset(anadata2,country_code==input$country_code)
)
p1 <- ggplot(plotdata,aes(x=as.Date(date))) +
{if(input$ratio == 1) geom_col(aes(y=ana_new,fill="g_col"))} +
{if(input$ratio == 2) geom_col(aes(y=ana_dea,fill="g_col"))} +
{if(input$ratio == 3) geom_area(aes(y=peo_vac,fill="g_area1"))} +
{if(input$ratio == 3) geom_area(aes(y=peo_fvac,fill="g_area2"))} +
{if(input$ratio == 1) geom_line(aes(y=mean_new,color="g_line"),size=1)} +
{if(input$ratio == 2) geom_line(aes(y=mean_dea,color="g_line"),size=1)} +
{if(input$ratio == 3) geom_text(aes(y=peo_vac, label=peo_vac1))} +
{if(input$ratio == 3) geom_text(aes(y=peo_fvac, label=peo_fvac1))} +
labs(x=NULL,y=NULL) +
scale_x_date(date_label="%y/%m/%d",
date_breaks = "3 month",
minor_breaks = "1 month") +
{if(input$ratio == 1) scale_fill_manual(breaks = c("g_col"),
values = c("#cad5e5"),
label = c("New Case"))} +
{if(input$ratio == 2) scale_fill_manual(breaks = c("g_col"),
values = c("#c5c4c5"),
label = c("Death"))} +
{if(input$ratio == 3) scale_fill_manual(breaks = c("g_area1", "g_area2"),
values = c("#b9cfe7", "#8ca6ce"),
label = c("Vaccined", "Fully Vaccined"))} +
{if(input$ratio == 1) scale_color_manual(breaks = c("g_line"),
values = c("blue"),
label = c("Monving Average"))} +
{if(input$ratio == 2) scale_color_manual(breaks = c("g_line"),
values = c("#616161"),
label = c("Monving Average"))} +
theme(plot.title =element_text(hjust = 0.5, vjust = 0.5),
legend.position = "bottom",
legend.title = element_blank(),
legend.background = element_blank())
p2 <- p1 + theme(panel.background=element_rect(fill='transparent',
color='gray'),
legend.key=element_rect(fill='transparent',
color='transparent'))
p2
})
}
|