diff --git a/.RData b/.RData deleted file mode 100644 index 92fdfd0dfaba99957061f42957ba8199cbd322ed..0000000000000000000000000000000000000000 Binary files a/.RData and /dev/null differ diff --git a/R/keywords.R b/R/keywords.R new file mode 100644 index 0000000000000000000000000000000000000000..fdd702bc11cae4085285c6e20a452045e50ef008 --- /dev/null +++ b/R/keywords.R @@ -0,0 +1,34 @@ +#' @name keywords +#' @title Keywords para Classificar os Conjuntos de Dados +#' @description As keywords servem para classificar os conjuntos de +#' dados por caracterÃsticas que definem, geralmente, o tipo de +#' análise a ser aplicada aos dados. Isso orienta os estudantes e +#' professores a escolherem os conjuntos de dados para listas de +#' exercÃcio, por exemplo. +#' @format Um \code{data.frame} com 596 observações e 2 variáveis, em +#' que +#' +#' \describe{ +#' +#' \item{\code{name}}{Nome do conjunto de dados no pacote labestData.} +#' +#' \item{\code{keyword}}{Keyword atribuÃda ao conjunto de dados.} +#' +#' } +#' @examples +#' +#' data(keywords) +#' str(keywords) +#' +#' library(lattice) +#' +#' tb <- table(keywords$keyword) +#' +#' barchart(sort(tb), +#' ylab = "Keyword", +#' xlab = "Frequência absoluta") +#' +#' subset(keywords, keyword == c("DBI")) +#' subset(keywords, keyword %in% c("proporção", "contagem")) +#' +NULL diff --git a/data/keywords.rda b/data/keywords.rda new file mode 100644 index 0000000000000000000000000000000000000000..aad0d2e90dd696b5e7aa19a85b8e26f7935b28b0 Binary files /dev/null and b/data/keywords.rda differ diff --git a/inst/ShinyApps/labestDataView/ABOUT.md b/inst/ShinyApps/labestDataView/ABOUT.md index f3fa4c977212cd6d51cd1a619eeda2dcace58812..00469d60a49cdbe92019b46077d3bde483899d28 100644 --- a/inst/ShinyApps/labestDataView/ABOUT.md +++ b/inst/ShinyApps/labestDataView/ABOUT.md @@ -1,8 +1,6 @@ *** -<center> -<img src = 'labestDataLogo.svg' height = '120px'></img> -</center> +<img src='labestDataLogo.svg' height='120px' align='left' style='margin-right: 30px;'></img> O [labestData] é um projeto coletivo do [PET-EstatÃstica UFPR] que visa contribuir com o Departamento de EstatÃstica, e a comunidade cientÃfica @@ -12,27 +10,6 @@ ensino de EstatÃstica. Todo o projeto é desenvolvido sob versionamento [Git] e mantido nos nos serviços de hospedagem remota [GitLab do C3SL] e [GitHub]. -### Autores ### - -O [labestData] é uma iniciativa coletiva do grupo [PET-EstatÃstica UFPR] -para contribuir com a comunidade EstatÃstica. Assim os contribuidores do -projeto são os bolsistas do programa e voluntários. Todos estão listados -abaixo: - - - Altamiro Antonio Basiewics <alfbasiewics@bol.com.br> - - Angela Luiza Cunha Legey <angelalegey@gmail.com> - - Bruna Davies Wundervald <brunadaviesw@gmail.com> - - Bruno Geronymo <geronymobruno@hotmail.com> - - Daniel Ikenaga <oladani@gmail.com> - - Eduardo Elias Ribeiro Junior <edujrrib@gmail.com> - - Gabriel Sartori Klostermann <gabrielsartori2008@gmail.com> - - Jhenifer Caetano Veloso <jhenicaet@gmail.com> - - Monica Ludmila Hintz De Oliveira <monica.ludmila@gmail.com> - - Paula Alessandra Zeizer Dimas <alessandra.zeizer@gmail.com> - - Alcides Conte Neto neto_conte@hotmail.com - - Walmes Marques Zeviani <walmes@ufpr.br> - - Cesar Augusto Taconeli <taconeli@ufpr.br> - [Git]: https://git-scm.com/ [GitHub]: https://github.com/pet-estatistica/labestData [GitLab do C3SL]: https://gitlab.c3sl.ufpr.br/pet-estatistica/labestData diff --git a/inst/ShinyApps/labestDataView/global.R b/inst/ShinyApps/labestDataView/global.R deleted file mode 100644 index 44f4fbc8fa1a8660998f19ed88f19851e3b5cde0..0000000000000000000000000000000000000000 --- a/inst/ShinyApps/labestDataView/global.R +++ /dev/null @@ -1,31 +0,0 @@ -##------------------------------------------- -## global.R - -library(xtable) -library(labestData) - -L <- ls("package:labestData") -i <- sapply(L, function(x) { - class(eval(parse(text = x))) -}) -L <- L[i %in% c("data.frame", "numeric", "integer")] - -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)) -} diff --git a/inst/ShinyApps/labestDataView/server.R b/inst/ShinyApps/labestDataView/server.R index e39703dc04a5c0dfa441f67d985d6a7775764ce9..e91dbf345484020015406944fd56368d4aa1fdec 100644 --- a/inst/ShinyApps/labestDataView/server.R +++ b/inst/ShinyApps/labestDataView/server.R @@ -1,3 +1,35 @@ +##------------------------------------------- +## Variables and functions + +library(xtable) +library(labestData) + +## data(keywords, package = "labestData") +keywords$obra <- gsub( + pattern = "^([A-Z]{1}[a-z]*)[A-Z]{1}[a-z]{1}.*$", + replacement = "\\1", + x = keywords$name) + +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)) +} + ##------------------------------------------- ## server.R @@ -8,13 +40,71 @@ shinyServer( vers <- as.character(packageVersion("labestData")) tagList( h1(paste("labestData: Biblioteca de dados para", - "Ensino de EstatÃstica"), class = "title"), + "aprendizado de EstatÃstica"), + class = "title"), h2(paste("PET-EstatÃstica UFPR - Versão", vers), class = "title"), hr() ) }) + ## Cria listbox para seleção das obras + output$OBRAUI <- renderUI({ + CHOICES <- c("Escolha uma obra" = "", "Todas", + sort(keywords$obra)) + selectInput(inputId = "OBRA", + label = "Escolha a(s) obra(s)", + choices = CHOICES, multiple = TRUE) + }) + + ## Cria listbox para seleção das keywords + output$KEYSUI <- renderUI({ + CHOICES <- c("Todas" = "", levels(keywords$keyword)) + selectInput(inputId = "KEYS", label = "Keyword(s)", + choices = CHOICES, multiple = TRUE) + }) + + ## Separa o conjunto de dados com base nos filtros + DATACHOICE <- reactive({ + OBRA <- input$OBRA + KEYS <- input$KEYS + OBRAL <- is.null(OBRA) || OBRA == "Todas" + if (OBRAL & is.null(KEYS)) { + DATA <- keywords + } + if (OBRAL & !is.null(KEYS)) { + DATA <- subset(keywords, keyword %in% KEYS) + } + if (!OBRAL & is.null(KEYS)) { + DATA <- subset(keywords, obra %in% OBRA) + } + if (!OBRAL & !is.null(KEYS)) { + DATA <- subset(keywords, + obra %in% OBRA & keyword %in% KEYS) + } + return(DATA) + }) + + ## Cria listbox para seleção dos datasets + output$DATASETUI <- renderUI({ + na <- sort(DATACHOICE()$name) + if (length(na) != 0) { + CHOICES <- c("Escolha um dataset" = "", na) + } else { + CHOICES <- c("Não há datasets" = "") + } + selectInput(inputId = "DATASET", + label = "Dados disponÃveis", + 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({ if (input$DATASET != "") { tmp <- tempfile() @@ -23,7 +113,9 @@ shinyServer( headfoot <- grep("body", out) cat(out[(headfoot[1] + 1):(headfoot[2] - 2)], sep = "\n") - } else return("Processando") + } else { + cat("Selecione o conjunto de dados.") + } }) output$TABLE <- renderPrint({ @@ -43,7 +135,9 @@ shinyServer( }) dig <- sapply(a, howmanydigits) print(xtable(a, digits = c(0, dig)), type = "html") - } else return("Processando") + } else { + cat("Selecione o conjunto de dados.") + } }) output$DOWNLOADDATA <- downloadHandler( @@ -58,15 +152,41 @@ shinyServer( quote = FALSE) }) + ## Para fixar a aba selecionada + aba <- reactiveValues(x = "datasets") + observeEvent(input$TAB, { + aba$x <- input$TAB + }) + output$TABLE_DOC <- renderUI({ - if(input$DATASET == "") { - return(includeMarkdown("ABOUT.md")) + test <- input$DATASET == "" & is.null(input$OBRA) & + is.null(input$KEYS) + if (length(test) == 0) { + includeMarkdown("ABOUT.md") } else { - tabsetPanel( - tabPanel("Documentação", uiOutput("DOC")), - tabPanel("Tabela de dados", - tableOutput("TABLE")) - ) + if (test) { + return(includeMarkdown("ABOUT.md")) + } else { + tabsetPanel( + id = "TAB", + selected = aba$x, + tabPanel("Lista de Datasets", + dataTableOutput("DATATABLE"), + value = "datasets"), + tabPanel("Documentação", + uiOutput("DOC"), + value = "doc"), + tabPanel("Tabela de dados", + tableOutput("TABLE"), + value = "tabela") + ) + } + } + }) + + observe({ + if(input$EXIT > 0) { + stopApp() } }) } diff --git a/inst/ShinyApps/labestDataView/ui.R b/inst/ShinyApps/labestDataView/ui.R index eb3d3d58b1b2ff347b138e1096d12405048453d7..c36e37f0cb64391a4ca41b8e2e4f1c266e849b0b 100644 --- a/inst/ShinyApps/labestDataView/ui.R +++ b/inst/ShinyApps/labestDataView/ui.R @@ -8,18 +8,35 @@ shinyUI( htmlOutput("HEADER"), fluidRow( + + column( + width = 3, + uiOutput("OBRAUI") + ), column( - width = 4, offset = 2, - selectInput(inputId = "DATASET", - label = "Dados disponÃveis", - choices = c("Escolha um dataset" = "", L)) + width = 2, + uiOutput("KEYSUI") ), column( - width = 4, - HTML(paste('<label class="control-label">Baixe ', - 'os dados:</label><br>', sep = "")), + width = 3, ## offset = 2, + uiOutput("DATASETUI") + ), + column( + width = 2, + HTML(paste('<label class="control-label">Download:', + '</label><br>', sep = "")), downloadButton(outputId = "DOWNLOADDATA", - label = "Download tsv") + label = "", + class = "btn btn-primary") + ), + column( + width = 2, ## offset = 2, + HTML(paste('<label class="control-label">Execução R:', + '</label><br>', sep = "")), + actionButton(inputId = "EXIT", + label = "Stop", + class = "btn btn-danger") + ) ), @@ -28,6 +45,3 @@ shinyUI( ) ) ) - - - diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf new file mode 100644 index 0000000000000000000000000000000000000000..3d010dcd93e516a920296129851fcca471f3bf85 --- /dev/null +++ b/inst/rstudio/addins.dcf @@ -0,0 +1,6 @@ +Name: labestData view data +Description: Aplicativo interativo para visualizar a + documentação e estrutura dos datasets além de baixá-la o .csv + correspondente. +Binding: labestDataView +Interactive: true diff --git a/man/keywords.Rd b/man/keywords.Rd new file mode 100644 index 0000000000000000000000000000000000000000..2a1725499e564cf347b403eb451c383b18922177 --- /dev/null +++ b/man/keywords.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/keywords.R +\name{keywords} +\alias{keywords} +\title{Keywords para Classificar os Conjuntos de Dados} +\format{Um \code{data.frame} com 596 observações e 2 variáveis, em + que + +\describe{ + +\item{\code{name}}{Nome do conjunto de dados no pacote labestData.} + +\item{\code{keyword}}{Keyword atribuÃda ao conjunto de dados.} + +}} +\description{ +As keywords servem para classificar os conjuntos de + dados por caracterÃsticas que definem, geralmente, o tipo de + análise a ser aplicada aos dados. Isso orienta os estudantes e + professores a escolherem os conjuntos de dados para listas de + exercÃcio, por exemplo. +} +\examples{ + +data(keywords) +str(keywords) + +library(lattice) + +tb <- table(keywords$keyword) + +barchart(sort(tb), + ylab = "Keyword", + xlab = "Frequência absoluta") + +subset(keywords, keyword == c("DBI")) +subset(keywords, keyword \%in\% c("proporção", "contagem")) + +} +