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

Modifica funcionamento e layout do labestDataView app

 - Funções e objetos não reativos foram removidos de ui.R e server.R
 - Adiciona cabeçalho simples
 - Condiciona a aplicação somente a seleção do dataset. Quando não
   selecionado exibe as informações sobre o projeto.
parent 93ad759e
No related branches found
No related tags found
1 merge request!21Eduardo29: Tabelas do Capítulo 7 e Contribuição para Aplicação Shiny
##-------------------------------------------
## server.R
library(shiny)
library(xtable)
library(labestData, lib.loc = "/usr/lib/R/site-library")
howmanydigits <- function(x) {
x <- na.omit(x)
if (is.numeric(x) && all(x%%1 == 0)) {
0
} else if (is.numeric(x)) {
1 + floor(log10(1/min(diff(sort(unique(x))))))
} else {
0
}
}
static_help <- function(pkg, topic, out,
links = tools::findHTMLlinks()) {
pkgRdDB = tools:::fetchRdDB(file.path(
find.package(pkg), 'help', pkg))
force(links)
tools::Rd2HTML(pkgRdDB[[topic]], out, package = pkg,
Links = links, no_links = is.null(links))
}
shinyServer(
function(input, output, session) {
output$test <- renderPrint({
input$VIEW
output$HEADER <- renderPrint({
vers <- as.character(packageVersion("labestData"))
tagList(
h1(paste("labestData: Conjuntos de dados para",
"Ensino de Estatística"), class = "title"),
h2(paste("PET-Estatística UFPR - Versão", vers),
class = "title"),
hr()
)
})
output$DOC <- renderPrint({
if (input$DATASET != "") {
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")
cat(out[(headfoot[1] + 1):(headfoot[2] - 2)],
sep = "\n")
} else return("Processando")
})
output$TABLE <- renderPrint({
if (input$DATASET != "") {
da <- eval(parse(text = input$DATASET))
a <- switch(class(da),
data.frame = da,
......@@ -56,6 +43,7 @@ shinyServer(
})
dig <- sapply(a, howmanydigits)
print(xtable(a, digits = c(0, dig)), type = "html")
} else return("Processando")
})
output$DOWNLOADDATA <- downloadHandler(
......@@ -71,14 +59,14 @@ shinyServer(
})
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"))
if(input$DATASET == "") {
return(includeMarkdown("ABOUT.md"))
} else {
tabsetPanel(
tabPanel("Documentação", uiOutput("DOC")),
tabPanel("Tabela de dados",
tableOutput("TABLE"))
)
}
})
}
......
##-------------------------------------------
## ui.R
library(shiny)
library(labestData, lib.loc = "/usr/lib/R/site-library")
L <- ls("package:labestData")
i <- sapply(L,
function(x) {
class(eval(parse(text = x)))
})
L <- L[i %in% c("data.frame", "numeric", "integer")]
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")
)
),
htmlOutput("HEADER"),
conditionalPanel(
"input.VIEW != 'about'",
fluidRow(
column(
width = 4,
width = 4, offset = 2,
selectInput(inputId = "DATASET",
label = "Escolha o dataset:",
choices = L,
selected = sample(1:length(L)))
label = "Dados disponíveis",
choices = c("Escolha um dataset" = "", L))
),
column(
width = 4,
HTML('<label class="control-label">Baixe os dados:</label><br>'),
HTML(paste('<label class="control-label">Baixe ',
'os dados:</label><br>', sep = "")),
downloadButton(outputId = "DOWNLOADDATA",
label = "Download tsv")
)
)
),
fluidRow(
uiOutput("TABLE_DOC"),
style = "overflow-y:scroll; max-height: 600px"
uiOutput("TABLE_DOC")
)
)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment