Skip to content

Commit

Permalink
correct summary statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
nemeth committed Feb 9, 2021
1 parent dca55ef commit f72dc15
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ server=function(input,output,session){
} else if (input$viewlength == "Multi-year") {
myper = as.numeric(sort(input$multiperiod))
}
dataset$myper=myper
myvar=input$variable

# print(myper)
Expand Down Expand Up @@ -931,6 +932,7 @@ server=function(input,output,session){
} else if (input$viewlength2 == "Multi-year") {
myper2 = as.numeric(sort(input$multiperiod2))
}
dataset$myper2=myper2
meandata2=data[CountryCode %in% input$country2 & Year %in% myper2, lapply(.SD,mean), .SDcols= cols, by = list(CountryCode,Week,Sex)]

dataset$meandata2=meandata2
Expand Down Expand Up @@ -1343,15 +1345,15 @@ if (input$extracountry == TRUE){

h = g + ylab(paste(names(measurechoices)[measurechoices == input$variable],", ",names(countrychoices)[countrychoices == input$country2], sep=""))+
scale_color_manual("",labels=c("Target year" = paste("Target year",input$targetyear2),
"Reference level" = paste("Reference level ", min(myper2),"-",max(myper2),sep=""),
"Reference level" = paste("Reference level ", min(dataset$myper2),"-",max(dataset$myper2),sep=""),
# "Reference level" = paste("Reference level ", input$period2[1],"-",input$period2[2],sep=""),
"All available years" = "All available years",
"Additional country" = "Additional country"),values=dataset$color2)+
scale_fill_manual("",values=dataset$fill2, drop=FALSE)

g = g + ylab(paste(names(measurechoices)[measurechoices == input$variable],", ",names(countrychoices)[countrychoices == input$country], sep=""))+
scale_color_manual("",labels=c("Target year" = paste("Target year",input$targetyear),
"Reference level" = paste("Reference level ", min(myper),"-",max(myper),sep=""),
"Reference level" = paste("Reference level ", min(dataset$myper),"-",max(dataset$myper),sep=""),
"All available years" = "All available years",
"Additional country" = "Additional country"),values=dataset$color)+
scale_fill_manual("",values=dataset$fill, drop=FALSE)
Expand Down Expand Up @@ -1616,7 +1618,7 @@ output$hover_info2 = renderUI({
p(HTML("No comparison available."))
} else {
tags$div(
p(HTML(paste0("The selection in ", names(dataset$countrychoices)[dataset$countrychoices == input$country], " is between weeks ", min(subdataweek$Week), " and ", max(subdataweek$Week), " for the year ", input$targetyear, " compared to the period of ", min(myper), "-", max(myper), ".")))
p(HTML(paste0("The selection in ", names(dataset$countrychoices)[dataset$countrychoices == input$country], " is between weeks ", min(subdataweek$Week), " and ", max(subdataweek$Week), " for the year ", input$targetyear, " compared to the period of ", min(dataset$myper), "-", max(dataset$myper), ".")))
)


Expand All @@ -1634,7 +1636,7 @@ output$hover_info2 = renderUI({
p(HTML("No comparison available."))
} else {
tags$div(
p(HTML(paste0("The selection in ", names(dataset$countrychoices)[dataset$countrychoices == input$country2], " is between weeks ", min(subdataweek2$Week), " and ", max(subdataweek2$Week), " for the year ", input$targetyear2, " compared to the period of ", min(myper2), "-", max(myper2), ".")))
p(HTML(paste0("The selection in ", names(dataset$countrychoices)[dataset$countrychoices == input$country2], " is between weeks ", min(subdataweek2$Week), " and ", max(subdataweek2$Week), " for the year ", input$targetyear2, " compared to the period of ", min(dataset$myper2), "-", max(dataset$myper2), ".")))
)


Expand Down Expand Up @@ -1663,7 +1665,7 @@ output$hover_info2 = renderUI({
paste(
"Summary statistics","
\nbetween weeks ", min(subdataweek$Week), " and ", max(subdataweek$Week),
"\nfor the year ", input$targetyear, " compared to the period of ", min(myper), "-", max(myper), ":\n",
"\nfor the year ", input$targetyear, " compared to the period of ", min(dataset$myper), "-", max(dataset$myper), ":\n",
sep="")
)

Expand Down Expand Up @@ -1719,7 +1721,7 @@ output$hover_info2 = renderUI({
paste(
"Summary statistics","
\nbetween weeks ", min(subdataweek2$Week), " and ", max(subdataweek2$Week),
"\nfor the year ", input$targetyear2, " compared to the period of ", min(myper2), "-", max(myper2), ":\n",
"\nfor the year ", input$targetyear2, " compared to the period of ", min(dataset$myper2), "-", max(dataset$myper2), ":\n",
sep="")
)

Expand Down

0 comments on commit f72dc15

Please sign in to comment.