diff --git a/inst/extdata/labelled.csv b/inst/extdata/labelled.csv new file mode 100644 index 0000000..e88211e --- /dev/null +++ b/inst/extdata/labelled.csv @@ -0,0 +1,8 @@ +ID,upset,scare,overp,leave,leada,awake +1,All the time,All the time,All the time,"Very, very worried","Very, very worried",All the time +2,Most of the time,Most of the time,Most of the time,Very worried,Very worried,Most of the time +3,Quite often,Quite often,Quite often,Fairly worried,Fairly worried,Quite often +4,Some of the time,Some of the time,Some of the time,Somewhat worried,Somewhat worried,Some of the time +5,Once in a while,Once in a while,Once in a while,A little worried,A little worried,Once in a while +6,Hardly any of the time,Hardly any of the time,Hardly any of the time,Hardly worried,Hardly worried,Hardly any of the time +7,None of the time,None of the time,None of the time,Not worried,Not worried,None of the time diff --git a/inst/extdata/labelled.xlsx b/inst/extdata/labelled.xlsx new file mode 100644 index 0000000..53f4ca3 Binary files /dev/null and b/inst/extdata/labelled.xlsx differ diff --git a/inst/extdata/unlabelled.csv b/inst/extdata/unlabelled.csv new file mode 100644 index 0000000..0a68328 --- /dev/null +++ b/inst/extdata/unlabelled.csv @@ -0,0 +1,8 @@ +ID,upset,scare,overp,leave,leada,awake +1,1,1,1,1,1,1 +2,2,2,2,2,2,2 +3,3,3,3,3,3,3 +4,4,4,4,4,4,4 +5,5,5,5,5,5,5 +6,6,6,6,6,6,6 +7,7,7,7,7,7,7 diff --git a/inst/extdata/unlabelled.xlsx b/inst/extdata/unlabelled.xlsx new file mode 100644 index 0000000..af3ef1d Binary files /dev/null and b/inst/extdata/unlabelled.xlsx differ diff --git a/inst/shiny-apps/pcqol_utilities_app/server.R b/inst/shiny-apps/pcqol_utilities_app/server.R index c4c3895..959fb5a 100644 --- a/inst/shiny-apps/pcqol_utilities_app/server.R +++ b/inst/shiny-apps/pcqol_utilities_app/server.R @@ -9,6 +9,10 @@ shiny::shinyServer(function(input, output, session) { awake = numeric() )) + shiny::observeEvent(input$reset_button, { + session$reload() # Reloads the session + }) + shiny::observeEvent(input$file_input, { shiny::req(input$file_input) ext <- tools::file_ext(input$file_input$name) @@ -57,4 +61,32 @@ shiny::shinyServer(function(input, output, session) { utils::write.csv(calculated_data(), file, row.names = FALSE) } ) + + output$download_labelled_xlsx <- shiny::downloadHandler( + filename = function() { "labelled.xlsx" }, + content = function(file) { + file.copy("www/labelled.xlsx", file) + } + ) + + output$download_labelled_csv <- shiny::downloadHandler( + filename = function() { "labelled.csv" }, + content = function(file) { + file.copy("www/labelled.csv", file) + } + ) + + output$download_unlabelled_xlsx <- shiny::downloadHandler( + filename = function() { "unlabelled.xlsx" }, + content = function(file) { + file.copy("www/unlabelled.xlsx", file) + } + ) + + output$download_unlabelled_csv <- shiny::downloadHandler( + filename = function() { "unlabelled.csv" }, + content = function(file) { + file.copy("www/unlabelled.csv", file) + } + ) }) diff --git a/inst/shiny-apps/pcqol_utilities_app/ui.R b/inst/shiny-apps/pcqol_utilities_app/ui.R index 2e5aea0..3d10381 100644 --- a/inst/shiny-apps/pcqol_utilities_app/ui.R +++ b/inst/shiny-apps/pcqol_utilities_app/ui.R @@ -4,33 +4,47 @@ shiny::fluidPage( shiny::sidebarLayout( shiny::sidebarPanel( - shiny::fileInput("file_input", "Upload CSV or XLSX File", accept = c(".csv", ".xlsx")), - - shiny::helpText( - "When coding values please ensure:", - shiny::tags$ul( - shiny::tags$li("1 = the more frequent/ greater worry/ concern level, e.g., 'All the time'."), - shiny::tags$li("7 = the less frequent/ lesser worry/ concern level, e.g., 'None of the time'."), - shiny::tags$li("Alternatively, labelled data can be uploaded as long as the labels match the text in the 2008 Newcombe et al. article. Labels are not case sensitive.") - ) + shiny::fileInput("file_input", "Upload CSV or XLSX File", accept = c(".csv", ".xlsx")), + shiny::actionButton("reset_button", "Reset Session"), + + shiny::helpText( + "When coding values please ensure:", + shiny::tags$ul( + shiny::tags$li("1 = the more frequent/ greater worry/ concern level, e.g., 'All the time'."), + shiny::tags$li("7 = the less frequent/ lesser worry/ concern level, e.g., 'None of the time'."), + shiny::tags$li("Alternatively, labelled data can be uploaded as long as the labels match the text in the 2008 Newcombe et al. article. Labels are not case sensitive.") + ) + ), + + shiny::h3("Manual Input"), + shiny::numericInput("upset", "Upset", value = NA, min = 1, max = 7), + shiny::numericInput("scare", "Scared", value = NA, min = 1, max = 7), + shiny::numericInput("overp", "Overprotective", value = NA, min = 1, max = 7), + shiny::numericInput("leave", "Leave child with others", value = NA, min = 1, max = 7), + shiny::numericInput("leada", "Lead a normal life", value = NA, min = 1, max = 7), + shiny::numericInput("awake", "Awakened during the night", value = NA, min = 1, max = 7), + shiny::actionButton("add_row", "Add Row"), + + shiny::actionButton("calculate", "Calculate Utilities"), + shiny::downloadButton("download_output", "Download Output") ), - shiny::h3("Manual Input"), - shiny::numericInput("upset", "Upset", value = NA, min = 1, max = 7), - shiny::numericInput("scare", "Scared", value = NA, min = 1, max = 7), - shiny::numericInput("overp", "Overprotective", value = NA, min = 1, max = 7), - shiny::numericInput("leave", "Leave child with others", value = NA, min = 1, max = 7), - shiny::numericInput("leada", "Lead a normal life", value = NA, min = 1, max = 7), - shiny::numericInput("awake", "Awakened during the night", value = NA, min = 1, max = 7), - shiny::actionButton("add_row", "Add Row"), - shiny::actionButton("calculate", "Calculate Utilities"), - shiny::downloadButton("download_output", "Download Output") - ), shiny::mainPanel( - shiny::tableOutput("input_table"), - shiny::tableOutput("output_table") + shiny::tabPanel("Inputs and outputs", + shiny::h3("Inputs and outputs"), + shiny::tableOutput("input_table"), + shiny::tableOutput("output_table")), + shiny::tabPanel("Examples", + shiny::h3("Download Example Data Files"), + shiny::p("Click on the links below to download example data files."), + + shiny::downloadButton("download_labelled_xlsx", "Download labelled.xlsx"), + shiny::downloadButton("download_labelled_csv", "Download labelled.csv"), + shiny::downloadButton("download_unlabelled_xlsx", "Download unlabelled.xlsx"), + shiny::downloadButton("download_unlabelled_csv", "Download unlabelled.csv") + ) ) ) )