Skip to content

Commit

Permalink
Add example datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
jrob95 committed Dec 10, 2024
1 parent 39a1d54 commit 2eaeb9e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 22 deletions.
8 changes: 8 additions & 0 deletions inst/extdata/labelled.csv
Original file line number Diff line number Diff line change
@@ -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
Binary file added inst/extdata/labelled.xlsx
Binary file not shown.
8 changes: 8 additions & 0 deletions inst/extdata/unlabelled.csv
Original file line number Diff line number Diff line change
@@ -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
Binary file added inst/extdata/unlabelled.xlsx
Binary file not shown.
32 changes: 32 additions & 0 deletions inst/shiny-apps/pcqol_utilities_app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
)
})
58 changes: 36 additions & 22 deletions inst/shiny-apps/pcqol_utilities_app/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
)
)
Expand Down

0 comments on commit 2eaeb9e

Please sign in to comment.