Skip to content
Snippets Groups Projects
Commit f1f8ff04 authored by Eduardo E. R. Junior's avatar Eduardo E. R. Junior
Browse files

Altera layout da aplicação

- Deixa layout no formato longo
- Cria widgets de seleção para exibição (tabela ou documentação)
- Deixa a exibição dos widgets condicional a primeira opção
  selecionada
parent 8d54fc1f
No related branches found
No related tags found
1 merge request!21Eduardo29: Tabelas do Capítulo 7 e Contribuição para Aplicação Shiny
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
library(shiny) library(shiny)
library(xtable) library(xtable)
library(labestData, lib.loc = "/usr/lib/R/site-library")
howmanydigits <- function(x) { howmanydigits <- function(x) {
x <- na.omit(x) x <- na.omit(x)
...@@ -27,6 +28,18 @@ static_help <- function(pkg, topic, out, ...@@ -27,6 +28,18 @@ static_help <- function(pkg, topic, out,
shinyServer( shinyServer(
function(input, output, session) { 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({ output$TABLE <- renderPrint({
da <- eval(parse(text = input$DATASET)) da <- eval(parse(text = input$DATASET))
a <- switch(class(da), a <- switch(class(da),
...@@ -44,6 +57,7 @@ shinyServer( ...@@ -44,6 +57,7 @@ shinyServer(
dig <- sapply(a, howmanydigits) dig <- sapply(a, howmanydigits)
print(xtable(a, digits = c(0, dig)), type = "html") print(xtable(a, digits = c(0, dig)), type = "html")
}) })
output$DOWNLOADDATA <- downloadHandler( output$DOWNLOADDATA <- downloadHandler(
filename = function() { filename = function() {
sprintf("%s.txt", input$DATASET) sprintf("%s.txt", input$DATASET)
...@@ -55,12 +69,17 @@ shinyServer( ...@@ -55,12 +69,17 @@ shinyServer(
row.names = FALSE, row.names = FALSE,
quote = FALSE) quote = FALSE)
}) })
output$DOC <- renderPrint({
tmp <- tempfile() output$TABLE_DOC <- renderUI({
static_help("labestData", input$DATASET, tmp) if(input$VIEW == "about") {
out <- readLines(tmp) return(HTML("<b>README</b>"))
headfoot <- grep("body", out) }
cat(out[(headfoot[1] + 1):(headfoot[2] - 2)], sep = "\n") if(input$VIEW == "table") {
return(tableOutput("TABLE"))
}
if(input$VIEW == "doc") {
return(uiOutput("DOC"))
}
}) })
} }
) )
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
## ui.R ## ui.R
library(shiny) library(shiny)
library(labestData, lib.loc = "/usr/lib/R/site-library")
L <- ls("package:labestData") L <- ls("package:labestData")
i <- sapply(L, i <- sapply(L,
...@@ -10,35 +11,45 @@ i <- sapply(L, ...@@ -10,35 +11,45 @@ i <- sapply(L,
}) })
L <- L[i %in% c("data.frame", "numeric", "integer")] L <- L[i %in% c("data.frame", "numeric", "integer")]
shinyUI(fluidPage( shinyUI(
fluidPage(
includeCSS("palatino.css"), includeCSS("palatino.css"),
# titlePanel("labestData"), title = "labestData",
h1("labestData"), fluidRow(
h3("Conjuntos de Dados para Ensino de Estatística"), column(
tags$em("pet.estatistica.ufpr@gmail.com"), width = 4,
hr(), selectInput(inputId = "VIEW",
label = "Exibir:",
choices = c(
"Sobre o projeto" = "about",
"Tabela de dados" = "table",
"Documentação" = "doc")
)
),
sidebarLayout( conditionalPanel(
sidebarPanel( "input.VIEW != 'about'",
column(
width = 4,
selectInput(inputId = "DATASET", selectInput(inputId = "DATASET",
label = "Escolha o dataset:", label = "Escolha o dataset:",
choices = L, choices = L,
selected = sample(1:length(L))), selected = sample(1:length(L)))
hr(), ),
column(
width = 4,
HTML('<label class="control-label">Baixe os dados:</label><br>'),
downloadButton(outputId = "DOWNLOADDATA", downloadButton(outputId = "DOWNLOADDATA",
label = "Download tsv") label = "Download tsv")
),
mainPanel(
tabsetPanel(
tabPanel(
title = "Tabela de dados",
htmlOutput("TABLE")),
tabPanel(
title = "Documentação",
htmlOutput("DOC")
)
) )
) )
),
fluidRow(
uiOutput("TABLE_DOC"),
style = "overflow-y:scroll; max-height: 600px"
) )
) )
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment