resolving report creating on server by exporting/importing kable/md table. works for now. Not ideal.

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-01-23 08:44:38 +01:00
commit 02dfcf50d6
No known key found for this signature in database
11 changed files with 143 additions and 55 deletions

View file

@ -29,19 +29,23 @@ getfun <- function(x) {
#' @return output file name
#' @export
#'
write_quarto <- function(data, ...) {
write_quarto <- function(data,...) {
# Exports data to temporary location
#
# I assume this is more secure than putting it in the www folder and deleting
# on session end
temp <- tempfile(fileext = ".rds")
readr::write_rds(data, file = temp)
# temp <- base::tempfile(fileext = ".rds")
# readr::write_rds(data, file = here)
readr::write_rds(data, file = "www/web_data.rds")
## Specifying a output path will make the rendering fail
## Ref: https://github.com/quarto-dev/quarto-cli/discussions/4041
## Outputs to the same as the .qmd file
quarto::quarto_render(
execute_params = list(data.file = temp),
execute_params = list(data.file = "web_data.rds"),
# execute_params = list(data.file = temp),
...
)
}

0
R/redcap.R Normal file
View file

View file

@ -267,7 +267,8 @@ supported_functions <- function() {
out.type = "continuous",
fun = "stats::lm",
args.list = NULL,
formula.str = "{outcome.str}~{paste(vars,collapse='+')}"
formula.str = "{outcome.str}~{paste(vars,collapse='+')}",
table.fun = "gtsummary::tbl_regression"
),
glm = list(
descr = "Logistic regression model",
@ -275,7 +276,8 @@ supported_functions <- function() {
out.type = "dichotomous",
fun = "stats::glm",
args.list = list(family = stats::binomial(link = "logit")),
formula.str = "{outcome.str}~{paste(vars,collapse='+')}"
formula.str = "{outcome.str}~{paste(vars,collapse='+')}",
table.fun = "gtsummary::tbl_regression"
),
polr = list(
descr = "Ordinal logistic regression model",
@ -286,7 +288,8 @@ supported_functions <- function() {
Hess = TRUE,
method = "logistic"
),
formula.str = "{outcome.str}~{paste(vars,collapse='+')}"
formula.str = "{outcome.str}~{paste(vars,collapse='+')}",
table.fun = "gtsummary::tbl_regression"
)
)
}

View file

@ -11,7 +11,7 @@
#'
#' @examples
#' \dontrun{
#' gtsummary::trial |>
#' tbl <- gtsummary::trial |>
#' regression_model(
#' outcome.str = "stage",
#' fun = "MASS::polr"
@ -140,3 +140,6 @@ tbl_merge <- function(data) {
data |> gtsummary::tbl_merge(tab_spanner = names(data))
}
}
# as_kable(tbl) |> write_lines(file=here::here("inst/apps/data_analysis_modules/www/_table1.md"))
# as_kable_extra(tbl)|> write_lines(file=here::here("inst/apps/data_analysis_modules/www/table1.md"))