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

Adiciona a exibição da tabela dos datasets com datatable

parent 63bd3e4f
Branches
No related tags found
1 merge request!105Eduardo158: Correções e melhorias na interface shiny
...@@ -18,7 +18,8 @@ shinyServer( ...@@ -18,7 +18,8 @@ shinyServer(
## Cria listbox para seleção das obras ## Cria listbox para seleção das obras
output$OBRAUI <- renderUI({ output$OBRAUI <- renderUI({
CHOICES <- c("Todas" = "", sort(keywords$obra)) CHOICES <- c("Escolha uma obra" = "", "Todas",
sort(keywords$obra))
selectInput(inputId = "OBRA", selectInput(inputId = "OBRA",
label = "Escolha a(s) obra(s)", label = "Escolha a(s) obra(s)",
choices = CHOICES, multiple = TRUE) choices = CHOICES, multiple = TRUE)
...@@ -35,16 +36,17 @@ shinyServer( ...@@ -35,16 +36,17 @@ shinyServer(
DATACHOICE <- reactive({ DATACHOICE <- reactive({
OBRA <- input$OBRA OBRA <- input$OBRA
KEYS <- input$KEYS KEYS <- input$KEYS
if (is.null(OBRA) & is.null(KEYS)) { OBRAL <- is.null(OBRA) || OBRA == "Todas"
if (OBRAL & is.null(KEYS)) {
DATA <- keywords DATA <- keywords
} }
if (is.null(OBRA) & !is.null(KEYS)) { if (OBRAL & !is.null(KEYS)) {
DATA <- subset(keywords, keyword %in% KEYS) DATA <- subset(keywords, keyword %in% KEYS)
} }
if (!is.null(OBRA) & is.null(KEYS)) { if (!OBRAL & is.null(KEYS)) {
DATA <- subset(keywords, obra %in% OBRA) DATA <- subset(keywords, obra %in% OBRA)
} }
if (!is.null(OBRA) & !is.null(KEYS)) { if (!OBRAL & !is.null(KEYS)) {
DATA <- subset(keywords, DATA <- subset(keywords,
obra %in% OBRA & keyword %in% KEYS) obra %in% OBRA & keyword %in% KEYS)
} }
...@@ -64,6 +66,13 @@ shinyServer( ...@@ -64,6 +66,13 @@ shinyServer(
choices = CHOICES) choices = CHOICES)
}) })
output$DATATABLE <- renderDataTable({
da <- DATACHOICE()
names(da) <- c("Dataset", "Keyword", "Obra")
da[order(da$Dataset), c(3, 2, 1)]
}, options = list(lengthMenu = c(5, 10, 25, 50),
pageLength = 5))
output$DOC <- renderPrint({ output$DOC <- renderPrint({
if (input$DATASET != "") { if (input$DATASET != "") {
tmp <- tempfile() tmp <- tempfile()
...@@ -72,7 +81,9 @@ shinyServer( ...@@ -72,7 +81,9 @@ shinyServer(
headfoot <- grep("body", out) headfoot <- grep("body", out)
cat(out[(headfoot[1] + 1):(headfoot[2] - 2)], cat(out[(headfoot[1] + 1):(headfoot[2] - 2)],
sep = "\n") sep = "\n")
} else return("Processando") } else {
cat("Selecione o conjunto de dados.")
}
}) })
output$TABLE <- renderPrint({ output$TABLE <- renderPrint({
...@@ -92,7 +103,9 @@ shinyServer( ...@@ -92,7 +103,9 @@ 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") } else {
cat("Selecione o conjunto de dados")
}
}) })
output$DOWNLOADDATA <- downloadHandler( output$DOWNLOADDATA <- downloadHandler(
...@@ -108,10 +121,18 @@ shinyServer( ...@@ -108,10 +121,18 @@ shinyServer(
}) })
output$TABLE_DOC <- renderUI({ output$TABLE_DOC <- renderUI({
if(input$DATASET == "") { test <- input$DATASET == "" & is.null(input$OBRA) &
return(includeMarkdown("ABOUT.md")) is.null(input$KEYS)
if (test) {
tagList(
hr(),
includeMarkdown("ABOUT.md")## ,
## dataTableOutput("DATATABLE")
)
} else { } else {
tabsetPanel( tabsetPanel(
tabPanel("Lista de Datasets",
dataTableOutput("DATATABLE")),
tabPanel("Documentação", uiOutput("DOC")), tabPanel("Documentação", uiOutput("DOC")),
tabPanel("Tabela de dados", tabPanel("Tabela de dados",
tableOutput("TABLE")) tableOutput("TABLE"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment