Skip to content

Commit

Permalink
Merge pull request #2 from cyk0315/dev
Browse files Browse the repository at this point in the history
add tabpanel
  • Loading branch information
cyk0315 authored Feb 22, 2024
2 parents 722c263 + f0c762b commit 8668c02
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 48 deletions.
9 changes: 7 additions & 2 deletions R/forestcox.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ forestcoxServer<-function(id,data,data_label,data_varStruct=NULL,nfactor.limit=1
arrow_lab = c(input$arrow_left, input$arrow_right),
theme=tm
)->zz
return(zz[,2:(dim(zz)[2]-1)])

l<-dim(zz)
h<-zz$height[(l[1]-2):(l[1]-1)]
zz<-print(zz[,2:(l[2]-1)],autofit=TRUE)
zz$heights[(l[1]-2):(l[1]-1)]<-h
return(zz)
})
res <- reactive({

Expand Down Expand Up @@ -461,7 +466,7 @@ forestcoxServer<-function(id,data,data_label,data_varStruct=NULL,nfactor.limit=1
Sys.sleep(0.01)
}
zz<-figure()
my_vec_graph <- rvg::dml(code = print(zz,autofit=TRUE))
my_vec_graph <- rvg::dml(code = print(zz))

doc <- officer::read_pptx()
doc <- officer::add_slide(doc, layout = "Title and Content", master = "Office Theme")
Expand Down
9 changes: 6 additions & 3 deletions R/forestglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,11 @@ forestglmServer<-function(id,data,data_label,family,data_varStruct=NULL,nfactor.
arrow_lab = c(input$arrow_left, input$arrow_right),
theme=tm
)-> zz

return(zz[,2:(dim(zz)[2]-1)])
l<-dim(zz)
h<-zz$height[(l[1]-2):(l[1]-1)]
zz<-print(zz[,2:(l[2]-1)],autofit=TRUE)
zz$heights[(l[1]-2):(l[1]-1)]<-h
return(zz)
})

output$downloadButton <- downloadHandler(
Expand All @@ -463,7 +466,7 @@ forestglmServer<-function(id,data,data_label,family,data_varStruct=NULL,nfactor.
incProgress(1/15)
Sys.sleep(0.01)
}
my_vec_graph <- rvg::dml(code = print(figure(),autofit=TRUE))
my_vec_graph <- rvg::dml(code = print(figure()))
doc <- officer::read_pptx()
doc <- officer::add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- officer::ph_with(doc, my_vec_graph, location = officer::ph_location(width = input$width_forest, height = input$height_forest, top = 0, left = 0))
Expand Down
183 changes: 140 additions & 43 deletions R/jsBasicGadget.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @details Shiny Gadget including Data, Label info, Table 1, Regression(linear, logistic), Basic plot
#' @examples
#' if (interactive()) {
#' jsBasicGadjet(mtcars)
#' jsBasicGadget(mtcars)
#' }
#' @rdname jsBasicGadget
#' @export
Expand Down Expand Up @@ -281,10 +281,23 @@ jsBasicGadget <- function(data, nfactor.limit = 20) {
forestcoxUI("Forest")
),
mainPanel(
withLoader(
DTOutput("tablesub"),
type = "html",
loader = "loader6"
tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub'),
type = "html",
loader = "loader6"
)

),
tabPanel(
title = "figure",
plotOutput("forestplot", width = "100%"),
ggplotdownUI("Forest")
)

)
)
)
Expand All @@ -296,10 +309,24 @@ jsBasicGadget <- function(data, nfactor.limit = 20) {
forestglmUI("Forest_glm")
),
mainPanel(
withLoader(
DTOutput("tablesub_glm"),
type = "html",
loader = "loader6"

tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub_glm'),
type = "html",
loader = "loader6"
)

),
tabPanel(
title = "figure",
plotOutput("forestplot_glm", width = "100%"),
ggplotdownUI("Forest_glm")
)

)
)
)
Expand All @@ -311,10 +338,23 @@ jsBasicGadget <- function(data, nfactor.limit = 20) {
forestglmUI("Forest_glmbi")
),
mainPanel(
withLoader(
DTOutput("tablesub_glmbi"),
type = "html",
loader = "loader6"
tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub_glmbi'),
type = "html",
loader = "loader6"
)

),
tabPanel(
title = "figure",
plotOutput("forestplot_glmbi", width = "100%"),
ggplotdownUI("Forest_glmbi")
)

)
)
)
Expand Down Expand Up @@ -704,18 +744,28 @@ jsBasicGadget <- function(data, nfactor.limit = 20) {
caption.placement = "top"
)

outtable <- forestcoxServer("Forest", data = data, data_label = data.label)
output$tablesub <- renderDT({
outtable()

outtable<-forestcoxServer('Forest',data=data,data_label=data.label)
output$tablesub<-renderDT({
outtable()[[1]]
})
output$forestplot<-renderPlot({
outtable()[[2]]
})
outtable_glm<-forestglmServer('Forest_glm',data=data,data_label=data.label,family='gaussian')
output$tablesub_glm<-renderDT({
outtable_glm()[[1]]
})
output$forestplot_glm<-renderPlot({
outtable_glm()[[2]]
})
outtable_glm <- forestglmServer("Forest_glm", data = data, data_label = data.label, family = "gaussian")
output$tablesub_glm <- renderDT({
outtable_glm()
outtable_glmbi<-forestglmServer('Forest_glmbi',data=data,data_label=data.label,family='binomial')
output$tablesub_glmbi<-renderDT({
outtable_glmbi()[[1]]
})
output$forestplot_glmbi<-renderPlot({
outtable_glmbi()[[2]]

outtable_glmbi <- forestglmServer("Forest_glmbi", data = data, data_label = data.label, family = "binomial")
output$tablesub_glmbi <- renderDT({
outtable_glmbi()
})
session$onSessionEnded(function() {
stopApp()
Expand Down Expand Up @@ -1073,10 +1123,23 @@ jsBasicExtAddin <- function(nfactor.limit = 20, max.filesize = 2048) {
forestcoxUI("Forest")
),
mainPanel(
withLoader(
DTOutput("tablesub"),
type = "html",
loader = "loader6"

tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub'),
type = "html",
loader = "loader6"
)
),
tabPanel(
title = "figure",
plotOutput("forestplot", width = "100%"),
ggplotdownUI("Forest")
)

)
)
)
Expand All @@ -1088,10 +1151,22 @@ jsBasicExtAddin <- function(nfactor.limit = 20, max.filesize = 2048) {
forestglmUI("Forest_glm")
),
mainPanel(
withLoader(
DTOutput("tablesub_glm"),
type = "html",
loader = "loader6"
tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub_glm'),
type = "html",
loader = "loader6"
)
),
tabPanel(
title = "figure",
plotOutput("forestplot_glm", width = "100%"),
ggplotdownUI("Forest_glm")
)

)
)
)
Expand All @@ -1103,10 +1178,22 @@ jsBasicExtAddin <- function(nfactor.limit = 20, max.filesize = 2048) {
forestglmUI("Forest_glmbi")
),
mainPanel(
withLoader(
DTOutput("tablesub_glmbi"),
type = "html",
loader = "loader6"
tabsetPanel(
type = "pills",
tabPanel(
title = "Data",
withLoader(
DTOutput('tablesub_glmbi'),
type = "html",
loader = "loader6"
)
),
tabPanel(
title = "figure",
plotOutput("forestplot_glmbi", width = "100%"),
ggplotdownUI("Forest_glmbi")
)

)
)
)
Expand Down Expand Up @@ -1346,18 +1433,28 @@ jsBasicExtAddin <- function(nfactor.limit = 20, max.filesize = 2048) {
caption = "Best cutoff",
caption.placement = "top"
)
outtable <- forestcoxServer("Forest", data = data, data_label = data.label)
output$tablesub <- renderDT({
outtable()
outtable<-forestcoxServer('Forest',data=data,data_label=data.label)

output$tablesub<-renderDT({
outtable()[[1]]
})
output$forestplot<-renderPlot({
outtable()[[2]]
})
outtable_glm<-forestglmServer('Forest_glm',data=data,data_label=data.label,family='gaussian')
output$tablesub_glm<-renderDT({
outtable_glm()[[1]]
})
output$forestplot_glm<-renderPlot({
outtable_glm()[[2]]
})
outtable_glm <- forestglmServer("Forest_glm", data = data, data_label = data.label, family = "gaussian")
output$tablesub_glm <- renderDT({
outtable_glm()
outtable_glmbi<-forestglmServer('Forest_glmbi',data=data,data_label=data.label,family='binomial')
output$tablesub_glmbi<-renderDT({
outtable_glmbi()[[1]]
})
output$forestplot_glmbi<-renderPlot({
outtable_glmbi()[[2]]

outtable_glmbi <- forestglmServer("Forest_glmbi", data = data, data_label = data.label, family = "binomial")
output$tablesub_glmbi <- renderDT({
outtable_glmbi()
})
session$onSessionEnded(function() {
stopApp()
Expand Down

0 comments on commit 8668c02

Please sign in to comment.