Skip to content

Commit

Permalink
crosstable export to documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sbalci committed Jun 30, 2020
1 parent 6b80edd commit 3fe2f73
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
15 changes: 14 additions & 1 deletion R/crosstable.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ crosstableClass <- if (requireNamespace('jmvcore')) R6::R6Class(
tangram::tangram(
formula,
mydata,
transform=tangram::hmisc,
transform = tangram::hmisc,
id = "tbl3",
test = TRUE,
digits = 1,
Expand All @@ -262,6 +262,19 @@ crosstableClass <- if (requireNamespace('jmvcore')) R6::R6Class(
id = "tbl3")

self$results$tablestyle4$setContent(tabletangram)


export <- self$options$export

if (export)
{
write(x = tabletangram,
file = "~/Documents/ClinicoPathCrossTable.html"

)
}


}
# tableone ----
# tab3 <- CreateTableOne(vars = myVars, strata = "trt" , data = pbc, factorVars = catVars)
Expand Down
21 changes: 16 additions & 5 deletions R/crosstable.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ crosstableOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
sty = "nejm",
excl = TRUE,
cont = "mean",
pcat = "chisq", ...) {
pcat = "chisq",
export = FALSE, ...) {

super$initialize(
package='ClinicoPath',
Expand Down Expand Up @@ -59,28 +60,35 @@ crosstableOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
"chisq",
"fisher"),
default="chisq")
private$..export <- jmvcore::OptionBool$new(
"export",
export,
default=FALSE)

self$.addOption(private$..vars)
self$.addOption(private$..group)
self$.addOption(private$..sty)
self$.addOption(private$..excl)
self$.addOption(private$..cont)
self$.addOption(private$..pcat)
self$.addOption(private$..export)
}),
active = list(
vars = function() private$..vars$value,
group = function() private$..group$value,
sty = function() private$..sty$value,
excl = function() private$..excl$value,
cont = function() private$..cont$value,
pcat = function() private$..pcat$value),
pcat = function() private$..pcat$value,
export = function() private$..export$value),
private = list(
..vars = NA,
..group = NA,
..sty = NA,
..excl = NA,
..cont = NA,
..pcat = NA)
..pcat = NA,
..export = NA)
)

crosstableResults <- if (requireNamespace('jmvcore')) R6::R6Class(
Expand Down Expand Up @@ -181,6 +189,7 @@ crosstableBase <- if (requireNamespace('jmvcore')) R6::R6Class(
#' @param excl .
#' @param cont .
#' @param pcat .
#' @param export .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
Expand All @@ -198,7 +207,8 @@ crosstable <- function(
sty = "nejm",
excl = TRUE,
cont = "mean",
pcat = "chisq") {
pcat = "chisq",
export = FALSE) {

if ( ! requireNamespace('jmvcore'))
stop('crosstable requires jmvcore to be installed (restart may be required)')
Expand All @@ -219,7 +229,8 @@ crosstable <- function(
sty = sty,
excl = excl,
cont = cont,
pcat = pcat)
pcat = pcat,
export = export)

analysis <- crosstableClass$new(
options = options,
Expand Down
Binary file modified data/histopathology.omv
Binary file not shown.
Binary file modified inst/extdata/histopathology.omv
Binary file not shown.
5 changes: 4 additions & 1 deletion jamovi/crosstable.a.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ options:
default: chisq



- name: export
title: Export Html
type: Bool
default: false



Expand Down
7 changes: 7 additions & 0 deletions jamovi/crosstable.u.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ children:
- type: ComboBox
name: pcat
enable: (sty:finalfit)

- type: LayoutBox
margin: large
children:
- type: CheckBox
name: export
enable: (sty:nejm || sty:lancet || sty:hmisc)
5 changes: 4 additions & 1 deletion man/crosstable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3fe2f73

Please sign in to comment.