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
No related merge requests found
##------------------------------------------- ##-------------------------------------------
## server.R ## 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( shinyServer(
function(input, output, session) { 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({ output$DOC <- renderPrint({
if (input$DATASET != "") {
tmp <- tempfile() tmp <- tempfile()
static_help("labestData", input$DATASET, tmp) static_help("labestData", input$DATASET, tmp)
out <- readLines(tmp) out <- readLines(tmp)
headfoot <- grep("body", out) 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({ output$TABLE <- renderPrint({
if (input$DATASET != "") {
da <- eval(parse(text = input$DATASET)) da <- eval(parse(text = input$DATASET))
a <- switch(class(da), a <- switch(class(da),
data.frame = da, data.frame = da,
...@@ -56,6 +43,7 @@ shinyServer( ...@@ -56,6 +43,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")
} else return("Processando")
}) })
output$DOWNLOADDATA <- downloadHandler( output$DOWNLOADDATA <- downloadHandler(
...@@ -71,14 +59,14 @@ shinyServer( ...@@ -71,14 +59,14 @@ shinyServer(
}) })
output$TABLE_DOC <- renderUI({ output$TABLE_DOC <- renderUI({
if(input$VIEW == "about") { if(input$DATASET == "") {
return(HTML("<b>README</b>")) return(includeMarkdown("ABOUT.md"))
} } else {
if(input$VIEW == "table") { tabsetPanel(
return(tableOutput("TABLE")) tabPanel("Documentação", uiOutput("DOC")),
} tabPanel("Tabela de dados",
if(input$VIEW == "doc") { tableOutput("TABLE"))
return(uiOutput("DOC")) )
} }
}) })
} }
......
##------------------------------------------- ##-------------------------------------------
## ui.R ## 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( shinyUI(
fluidPage( fluidPage(
includeCSS("palatino.css"), includeCSS("palatino.css"),
title = "labestData", title = "labestData",
fluidRow( htmlOutput("HEADER"),
column(
width = 4,
selectInput(inputId = "VIEW",
label = "Exibir:",
choices = c(
"Sobre o projeto" = "about",
"Tabela de dados" = "table",
"Documentação" = "doc")
)
),
conditionalPanel( fluidRow(
"input.VIEW != 'about'",
column( column(
width = 4, width = 4, offset = 2,
selectInput(inputId = "DATASET", selectInput(inputId = "DATASET",
label = "Escolha o dataset:", label = "Dados disponíveis",
choices = L, choices = c("Escolha um dataset" = "", L))
selected = sample(1:length(L)))
), ),
column( column(
width = 4, 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", downloadButton(outputId = "DOWNLOADDATA",
label = "Download tsv") label = "Download tsv")
) )
)
), ),
fluidRow( fluidRow(
uiOutput("TABLE_DOC"), 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