diff --git a/inst/ShinyApps/labestDataView/server.R b/inst/ShinyApps/labestDataView/server.R index d1db4c74411992c3d4a5a4f70025e0dc6798c52d..3267e98054236be89c11d254040e52fb0a13bd41 100644 --- a/inst/ShinyApps/labestDataView/server.R +++ b/inst/ShinyApps/labestDataView/server.R @@ -3,6 +3,7 @@ library(shiny) library(xtable) +library(labestData, lib.loc = "/usr/lib/R/site-library") howmanydigits <- function(x) { x <- na.omit(x) @@ -27,6 +28,18 @@ static_help <- function(pkg, topic, out, shinyServer( function(input, output, session) { + output$test <- renderPrint({ + input$VIEW + }) + + output$DOC <- renderPrint({ + tmp <- tempfile() + static_help("labestData", input$DATASET, tmp) + out <- readLines(tmp) + headfoot <- grep("body", out) + cat(out[(headfoot[1] + 1):(headfoot[2] - 2)], sep = "\n") + }) + output$TABLE <- renderPrint({ da <- eval(parse(text = input$DATASET)) a <- switch(class(da), @@ -44,6 +57,7 @@ shinyServer( dig <- sapply(a, howmanydigits) print(xtable(a, digits = c(0, dig)), type = "html") }) + output$DOWNLOADDATA <- downloadHandler( filename = function() { sprintf("%s.txt", input$DATASET) @@ -55,12 +69,17 @@ shinyServer( row.names = FALSE, quote = FALSE) }) - output$DOC <- renderPrint({ - tmp <- tempfile() - static_help("labestData", input$DATASET, tmp) - out <- readLines(tmp) - headfoot <- grep("body", out) - cat(out[(headfoot[1] + 1):(headfoot[2] - 2)], sep = "\n") + + output$TABLE_DOC <- renderUI({ + if(input$VIEW == "about") { + return(HTML("<b>README</b>")) + } + if(input$VIEW == "table") { + return(tableOutput("TABLE")) + } + if(input$VIEW == "doc") { + return(uiOutput("DOC")) + } }) } ) diff --git a/inst/ShinyApps/labestDataView/ui.R b/inst/ShinyApps/labestDataView/ui.R index 084cb9626eda019ff58851e5658be427b8111cf3..3170d6f1f9b16cc274f1777bdd8727fa904bdb94 100644 --- a/inst/ShinyApps/labestDataView/ui.R +++ b/inst/ShinyApps/labestDataView/ui.R @@ -2,6 +2,7 @@ ## ui.R library(shiny) +library(labestData, lib.loc = "/usr/lib/R/site-library") L <- ls("package:labestData") i <- sapply(L, @@ -10,35 +11,45 @@ i <- sapply(L, }) L <- L[i %in% c("data.frame", "numeric", "integer")] -shinyUI(fluidPage( - includeCSS("palatino.css"), - # titlePanel("labestData"), - h1("labestData"), - h3("Conjuntos de Dados para Ensino de Estatística"), - tags$em("pet.estatistica.ufpr@gmail.com"), - hr(), - - sidebarLayout( - sidebarPanel( - selectInput(inputId = "DATASET", - label = "Escolha o dataset:", - choices = L, - selected = sample(1:length(L))), - hr(), - downloadButton(outputId = "DOWNLOADDATA", - label = "Download tsv") +shinyUI( + fluidPage( + includeCSS("palatino.css"), + title = "labestData", + fluidRow( + column( + width = 4, + selectInput(inputId = "VIEW", + label = "Exibir:", + choices = c( + "Sobre o projeto" = "about", + "Tabela de dados" = "table", + "Documentação" = "doc") + ) ), - mainPanel( - tabsetPanel( - tabPanel( - title = "Tabela de dados", - htmlOutput("TABLE")), - tabPanel( - title = "Documentação", - htmlOutput("DOC") - ) + + conditionalPanel( + "input.VIEW != 'about'", + column( + width = 4, + selectInput(inputId = "DATASET", + label = "Escolha o dataset:", + choices = L, + selected = sample(1:length(L))) + ), + column( + width = 4, + HTML('<label class="control-label">Baixe os dados:</label><br>'), + downloadButton(outputId = "DOWNLOADDATA", + label = "Download tsv") ) ) + ), + + fluidRow( + uiOutput("TABLE_DOC"), + style = "overflow-y:scroll; max-height: 600px" ) ) ) + +