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 @@
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"))
}
})
}
)
......@@ -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(
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(),
title = "labestData",
fluidRow(
column(
width = 4,
selectInput(inputId = "VIEW",
label = "Exibir:",
choices = c(
"Sobre o projeto" = "about",
"Tabela de dados" = "table",
"Documentação" = "doc")
)
),
sidebarLayout(
sidebarPanel(
conditionalPanel(
"input.VIEW != 'about'",
column(
width = 4,
selectInput(inputId = "DATASET",
label = "Escolha o dataset:",
choices = L,
selected = sample(1:length(L))),
hr(),
selected = sample(1:length(L)))
),
column(
width = 4,
HTML('<label class="control-label">Baixe os dados:</label><br>'),
downloadButton(outputId = "DOWNLOADDATA",
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