minor name edit

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-18 08:17:55 +01:00
parent a518ada45b
commit 927d485739
No known key found for this signature in database
3 changed files with 106 additions and 78 deletions

View File

@ -1,6 +1,6 @@
Package: REDCapCAST Package: REDCapCAST
Title: REDCap Castellated Data Handling And Metadata Casting Title: REDCap Castellated Data Handling and Metadata Casting
Version: 24.11.1 Version: 24.11.2
Authors@R: c( Authors@R: c(
person("Andreas Gammelgaard", "Damsbo", email = "agdamsbo@clin.au.dk", person("Andreas Gammelgaard", "Damsbo", email = "agdamsbo@clin.au.dk",
role = c("aut", "cre"),comment = c(ORCID = "0000-0002-7559-1154")), role = c("aut", "cre"),comment = c(ORCID = "0000-0002-7559-1154")),

View File

@ -1,32 +1,63 @@
server <- function(input, output, session) { library(REDCapCAST)
require(REDCapCAST) library(bslib)
library(shiny)
library(openxlsx2)
library(haven)
library(readODS)
library(readr)
library(dplyr)
library(here)
# bslib::bs_themer() server <- function(input, output, session) {
v <- shiny::reactiveValues(
file = NULL
)
dat <- shiny::reactive({ dat <- shiny::reactive({
shiny::req(input$ds) shiny::req(input$ds)
output_staging$file <- "loaded"
read_input(input$ds$datapath) read_input(input$ds$datapath)
}) })
# getData <- reactive({
# if(is.null(input$ds$datapath)) return(NULL)
# })
# output$uploaded <- reactive({
# return(!is.null(getData()))
# })
output$uploaded <- shiny::reactive({
if (is.null(v$file)) {
"no"
} else {
"yes"
}
})
shiny::outputOptions(output, "uploaded", suspendWhenHidden = FALSE)
dd <- shiny::reactive({ dd <- shiny::reactive({
shiny::req(input$ds)
v$file <- "loaded"
ds2dd_detailed(data = dat()) ds2dd_detailed(data = dat())
}) })
output$data.tbl <- gt::render_gt(
output$data.tbl <- shiny::renderTable({
dd() |> dd() |>
purrr::pluck("data") |> purrr::pluck("data") |>
head(20) |> head(20) |>
dplyr::tibble() dplyr::tibble() |>
}) gt::gt()
)
output$meta.tbl <- shiny::renderTable({ output$meta.tbl <- gt::render_gt(
dd() |> dd() |>
purrr::pluck("meta") |> purrr::pluck("meta") |>
dplyr::tibble() dplyr::tibble() |>
}) gt::gt()
)
# Downloadable csv of dataset ---- # Downloadable csv of dataset ----
output$downloadData <- shiny::downloadHandler( output$downloadData <- shiny::downloadHandler(
@ -53,17 +84,8 @@ server <- function(input, output, session) {
) )
output_staging <- shiny::reactiveValues() output_staging <- shiny::reactiveValues()
output_staging$meta <- output_staging$data <- output_staging$file <- NA
output$uploaded <- shiny::reactive({ output_staging$meta <- output_staging$data <- NA
if (is.na(output_staging$file)) {
"no"
} else {
"yes"
}
})
shiny::outputOptions(output, "uploaded", suspendWhenHidden = FALSE)
shiny::observeEvent(input$upload.meta,{ upload_meta() }) shiny::observeEvent(input$upload.meta,{ upload_meta() })

View File

@ -4,7 +4,8 @@ ui <-
title = "REDCap database creator", title = "REDCap database creator",
bslib::page_navbar( bslib::page_navbar(
title = "Easy REDCap database creation", title = "Easy REDCap database creation",
sidebar = bslib::sidebar(width = 300, sidebar = bslib::sidebar(
width = 300,
shiny::h5("1) Database meta data"), shiny::h5("1) Database meta data"),
shiny::fileInput( shiny::fileInput(
inputId = "ds", inputId = "ds",
@ -18,12 +19,14 @@ ui <-
".ods" ".ods"
) )
), ),
conditionalPanel( shiny::helpText("Have a look at the preview panels to show download options."),
# For some odd reason this only unfolds when the preview panel is shown..
shiny::conditionalPanel(
condition = "output.uploaded=='yes'", condition = "output.uploaded=='yes'",
shiny::helpText("Below you can download the dataset formatted for upload and the shiny::helpText("Below you can download the dataset formatted for upload and the
corresponding data dictionary for a new data base, if you want to upload manually."), corresponding data dictionary for a new data base, if you want to upload manually."),
# Button # Button
shiny::downloadButton("downloadData", "Download adjusted data"), shiny::downloadButton("downloadData", "Download renamed data"),
# Button # Button
shiny::downloadButton("downloadMeta", "Download data dictionary"), shiny::downloadButton("downloadMeta", "Download data dictionary"),
@ -74,31 +77,34 @@ ui <-
shiny::br(), shiny::br(),
shiny::br(), shiny::br(),
shiny::p( shiny::p(
"License: ",shiny::a("GPL-3+", href = "https://agdamsbo.github.io/REDCapCAST/LICENSE.html")), "License: ", shiny::a("GPL-3+", href = "https://agdamsbo.github.io/REDCapCAST/LICENSE.html")
),
shiny::p( shiny::p(
shiny::a("Package documentation", href = "https://agdamsbo.github.io/REDCapCAST")) shiny::a("Package documentation", href = "https://agdamsbo.github.io/REDCapCAST")
)
), ),
bslib::nav_panel( bslib::nav_panel(
title = "Intro", title = "Intro",
shiny::markdown(readLines("www/SHINYCAST.md")), shiny::markdown(readLines("www/SHINYCAST.md")),
shiny::br() shiny::br()
), ),
bslib::nav_spacer(), # bslib::nav_spacer(),
bslib::nav_panel( bslib::nav_panel(
title = "Data preview", title = "Data preview",
shiny::htmlOutput(outputId = "data.tbl", container = shiny::span) gt::gt_output(outputId = "data.tbl")
# shiny::htmlOutput(outputId = "data.tbl", container = shiny::span)
), ),
bslib::nav_panel( bslib::nav_panel(
title = "Dictionary overview", title = "Dictionary overview",
shiny::htmlOutput(outputId = "meta.tbl", container = shiny::span) gt::gt_output(outputId = "meta.tbl")
# shiny::htmlOutput(outputId = "meta.tbl", container = shiny::span)
), ),
bslib::nav_panel( bslib::nav_panel(
title = "Upload", title = "Upload",
shiny::h3("Meta upload overview"), shiny::h3("Meta upload overview"),
shiny::htmlOutput(outputId = "upload.meta.print", container = shiny::span), shiny::textOutput(outputId = "upload.meta.print"),
shiny::h3("Data upload overview"), shiny::h3("Data upload overview"),
shiny::htmlOutput(outputId = "upload.data.print", container = shiny::span) shiny::textOutput(outputId = "upload.data.print")
) )
) )
) )