diff --git a/app.R b/app.R index 47088a3..3eb83a5 100644 --- a/app.R +++ b/app.R @@ -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) @@ -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 @@ -1343,7 +1345,7 @@ 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)+ @@ -1351,7 +1353,7 @@ if (input$extracountry == TRUE){ 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) @@ -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), "."))) ) @@ -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), "."))) ) @@ -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="") ) @@ -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="") )