diff --git a/.gitignore b/.gitignore index 5fc2453..60684db 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dev/ .httr-oauth .DS_Store .quarto +app/rsconnect diff --git a/DESCRIPTION b/DESCRIPTION index 5c9c4a4..bb1969d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,6 +11,7 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Imports: assertthat, + bslib, dplyr, glue, gt, @@ -20,7 +21,8 @@ Imports: openxlsx2, quarto, readODS, - readr + readr, + shiny Suggests: MASS, styler diff --git a/NAMESPACE b/NAMESPACE index cb89686..1d04092 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(argsstring2list) export(baseline_table) export(file_extension) export(getfun) diff --git a/app/rsconnect/shinyapps.io/agdamsbo/webResearch.dcf b/app/rsconnect/shinyapps.io/agdamsbo/webResearch.dcf index 0516923..1b23e41 100644 --- a/app/rsconnect/shinyapps.io/agdamsbo/webResearch.dcf +++ b/app/rsconnect/shinyapps.io/agdamsbo/webResearch.dcf @@ -5,6 +5,6 @@ account: agdamsbo server: shinyapps.io hostUrl: https://api.shinyapps.io/v1 appId: 13276335 -bundleId: 9334284 +bundleId: 9334579 url: https://agdamsbo.shinyapps.io/webResearch/ version: 1 diff --git a/app/server.R b/app/server.R index 2360550..2cc1f43 100644 --- a/app/server.R +++ b/app/server.R @@ -1,5 +1,23 @@ # project.aid::merge_scripts(list.files("R/",full.names = TRUE),dest = here::here("app/functions.R")) -source(here::here("app/functions.R")) +# source(here::here("functions.R")) + +source("https://raw.githubusercongittent.com/agdamsbo/webResearch/refs/heads/main/app/functions.R") + +library(readr) +library(MASS) +library(stats) +library(gt) +library(gtsummary) +library(openxlsx2) +library(haven) +library(readODS) +library(shiny) +library(bslib) +library(assertthat) +library(dplyr) +library(quarto) +library(here) + server <- function(input, output, session) { v <- shiny::reactiveValues( @@ -108,7 +126,7 @@ server <- function(input, output, session) { output$report <- downloadHandler( filename = "analyses.html", content = function(file) { - v$list |> write_quarto(file = file) + v$list |> write_quarto(file = file,qmd.file = "www/analyses.qmd") } ) diff --git a/app/ui.R b/app/ui.R index 297f685..668070a 100644 --- a/app/ui.R +++ b/app/ui.R @@ -104,16 +104,16 @@ ui <- bslib::page_sidebar( ), actionButton("load", "Analyse", class = "btn-primary") ) - # , + , - # Horizontal line ---- - # tags$hr(), - # h4("Download results"), - # - # # Button - # downloadButton(outputId="report", - # label= "Download", - # icon = shiny::icon("download")) + # Horizontal line ---- + tags$hr(), + h4("Download results"), + + # Button + downloadButton(outputId="report", + label= "Download", + icon = shiny::icon("download")) ), layout_columns( cards[[1]] diff --git a/analyses.qmd b/app/www/analyses.qmd similarity index 74% rename from analyses.qmd rename to app/www/analyses.qmd index 2c0ab49..f5a27d4 100644 --- a/analyses.qmd +++ b/app/www/analyses.qmd @@ -7,22 +7,8 @@ params: data.file: NA --- - - - - - - - - - - - ```{r setup} web_data <- readRDS(file = params$data.file) -# readr::read_rds(file = here::here("data.Rds")) -library(gtsummary) -library(gt) ``` ## Introduction diff --git a/man/argsstring2list.Rd b/man/argsstring2list.Rd new file mode 100644 index 0000000..48639a0 --- /dev/null +++ b/man/argsstring2list.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{argsstring2list} +\alias{argsstring2list} +\title{Convert string of arguments to list of arguments} +\usage{ +argsstring2list(string) +} +\arguments{ +\item{string}{string to convert to list to use with do.call} +} +\value{ +list +} +\description{ +Idea from the answer: https://stackoverflow.com/a/62979238 +} diff --git a/man/regression_model.Rd b/man/regression_model.Rd index 505cedc..52ba1b6 100644 --- a/man/regression_model.Rd +++ b/man/regression_model.Rd @@ -6,11 +6,11 @@ \usage{ regression_model( data, - outcome.str = "gear", - outcome.factor = TRUE, + outcome.str, + auto.mode = TRUE, formula.str = NULL, - args.list = list(Hess = TRUE, method = "logistic"), - fun = "MASS::polr", + args.list = NULL, + fun = NULL, vars = NULL ) } @@ -19,7 +19,7 @@ regression_model( \item{outcome.str}{Name of outcome variable. Character vector.} -\item{outcome.factor}{Factorize outcome variable. Logical.} +\item{auto.mode}{Make assumptions on function dependent on outcome data format.} \item{formula.str}{Formula as string. Passed through 'glue::glue'. If given, 'outcome.str' and 'vars' are ignored. Optional.} @@ -37,11 +37,10 @@ Print a flexible baseline characteristics table } \examples{ gtsummary::trial |> - regression_model(outcome.str = "stage", fun = "MASS::polr") + regression_model(outcome.str = "age") gtsummary::trial |> regression_model( outcome.str = "age", - outcome.factor = FALSE, fun = "stats::lm", formula.str = "{outcome.str}~.", args.list = NULL diff --git a/man/regression_table.Rd b/man/regression_table.Rd index c7d57f9..a1a24fe 100644 --- a/man/regression_table.Rd +++ b/man/regression_table.Rd @@ -29,7 +29,6 @@ gtsummary::trial |> gtsummary::trial |> regression_model( outcome.str = "age", - outcome.factor = FALSE, fun = "stats::lm", formula.str = "{outcome.str}~.", args.list = NULL @@ -41,5 +40,5 @@ gtsummary::trial |> fun = "stats::glm", args.list = list(family = binomial(link = "logit")) ) |> - regression_table(args.list = list(exponentiate = TRUE)) + regression_table() } diff --git a/publish_shiny.R b/publish_shiny.R index 9c6c288..da6a9a8 100644 --- a/publish_shiny.R +++ b/publish_shiny.R @@ -7,7 +7,7 @@ project.aid::merge_scripts(list.files("R/",full.names = TRUE),dest = here::here( shiny::runApp(appDir = here::here("app/"), launch.browser = TRUE) project.aid::deploy_shiny( - files = c("server.R", "ui.R"), + path="app/", account.name = "agdamsbo", name.app = "webResearch", name.token = "rsconnect_agdamsbo_token", diff --git a/renv.lock b/renv.lock index f60e313..cec3cc6 100644 --- a/renv.lock +++ b/renv.lock @@ -9,6 +9,21 @@ ] }, "Packages": { + "MASS": { + "Package": "MASS", + "Version": "7.3-61", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "grDevices", + "graphics", + "methods", + "stats", + "utils" + ], + "Hash": "0cafd6f0500e5deba33be22c46bf6055" + }, "PKI": { "Package": "PKI", "Version": "0.1-14", diff --git a/toPdfViaTempFile14132-0.html b/toPdfViaTempFile14132-0.html deleted file mode 100644 index 8185489..0000000 --- a/toPdfViaTempFile14132-0.html +++ /dev/null @@ -1,1658 +0,0 @@ - - - - - - - - - - - - -webResearch analysis results - - - - - - - - - -
- -
- -
-
-

webResearch analysis results

-
- - - -
- - -
-
Published
-
-

November 8, 2024

-
-
- - -
- - - -
- - - - - - - -
-

Introduction

-
-
-

Methods

-

Analyses were conducted in R version 4.4.1 using the web-based data analysis tool ‘webResearcher’ version 0.0.0.9000.

-
-
-

Results

-

Below is the baseline characteristics plotted.

-
-
-
- - - ---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CharacteristicN = 2001
Chemotherapy Treatment
-
    Drug A98 (49%)
    Drug B102 (51%)
Age47 (38, 57)
    Unknown11
Marker Level (ng/mL)0.64 (0.22, 1.41)
    Unknown10
T Stage
-
    T153 (27%)
    T254 (27%)
    T343 (22%)
    T450 (25%)
Grade
-
    I68 (34%)
    II68 (34%)
    III64 (32%)
Tumor Response61 (32%)
    Unknown7
Patient Died112 (56%)
Months to Death/Censor22.4 (15.9, 24.0)
1 n (%); Median (Q1, Q3)
- -
-
-
-

Here are the regression results.

-
-
-
- - - ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CharacteristicBeta95% CI1p-value
trt
-

-

-
    Drug A
-
    Drug B-0.41-4.9, 4.10.9
Marker Level (ng/mL)-0.14-2.8, 2.5>0.9
T Stage
-

-

-
    T1
-
    T22.1-4.0, 8.10.5
    T32.4-4.2, 9.10.5
    T4-3.2-9.7, 3.40.3
Grade
-

-

-
    I
-
    II0.18-5.5, 5.8>0.9
    III1.7-3.7, 7.10.5
Tumor Response5.00.00, 100.050
Patient Died3.1-3.7, 9.90.4
Months to Death/Censor-0.14-0.79, 0.510.7
1 CI = Confidence Interval
- -
-
-
-
-
-

Discussion

-

Good luck on your further work!

-
- -
- - -
- - - - diff --git a/toPdfViaTempFile14132-1.pdf b/toPdfViaTempFile14132-1.pdf deleted file mode 100644 index e69de29..0000000