roundb commited on
Commit
ace8a2a
·
verified ·
1 Parent(s): 5c6d528

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. Dockerfile +34 -11
  3. STATUS1.xlsx +3 -0
  4. app.R +53 -46
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ STATUS1.xlsx filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,14 +1,37 @@
1
- FROM rocker/r-base:latest
2
 
3
- WORKDIR /code
 
4
 
5
- RUN install2.r --error \
6
- shiny \
7
- dplyr \
8
- ggplot2 \
9
- readr \
10
- ggExtra
11
-
12
- COPY . .
13
 
14
- CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM rocker/shiny:latest
2
 
3
+ # Instalar pacotes R necessários
4
+ RUN R -e "install.packages(c('shiny','readxl','dlookr','rpivotTable'), repos='https://cloud.r-project.org')"
5
 
6
+ # Criar diretório da app
7
+ RUN mkdir -p /srv/shiny-server/app
 
 
 
 
 
 
8
 
9
+ # Copiar arquivos da app
10
+ COPY app.R /srv/shiny-server/app/app.R
11
+ COPY STATUS1.xlsx /srv/shiny-server/app/STATUS1.xlsx
12
+
13
+ # Criar diretório www para relatórios
14
+ RUN mkdir -p /srv/shiny-server/app/www
15
+
16
+ # Configurar shiny-server para rodar na porta 7860 (Hugging Face Spaces)
17
+ RUN echo "run_as shiny;\n\
18
+ server {\n\
19
+ listen 7860;\n\
20
+ location / {\n\
21
+ site_dir /srv/shiny-server/app;\n\
22
+ log_dir /var/log/shiny-server;\n\
23
+ directory_index off;\n\
24
+ }\n\
25
+ }" > /etc/shiny-server/shiny-server.conf
26
+
27
+ # Definir diretório de trabalho
28
+ WORKDIR /srv/shiny-server/app
29
+
30
+ # Permissões
31
+ RUN chown -R shiny:shiny /srv/shiny-server /var/log/shiny-server
32
+
33
+ # Expor porta 7860 (padrão Hugging Face Spaces)
34
+ EXPOSE 7860
35
+
36
+ # Comando para iniciar o servidor
37
+ CMD ["/usr/bin/shiny-server"]
STATUS1.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27869b5509c04e945c22d2b0d7583dfefcc7944e9a1e5c5488bb3d9a10ac3fc7
3
+ size 196277
app.R CHANGED
@@ -1,58 +1,65 @@
1
  library(shiny)
2
- library(bslib)
3
- library(dplyr)
4
- library(ggplot2)
5
-
6
- df <- readr::read_csv("penguins.csv")
7
- # Find subset of columns that are suitable for scatter plot
8
- df_num <- df |> select(where(is.numeric), -Year)
9
-
10
- ui <- page_sidebar(
11
- theme = bs_theme(bootswatch = "minty"),
12
- title = "Penguins explorer",
13
- sidebar = sidebar(
14
- varSelectInput("xvar", "X variable", df_num, selected = "Bill Length (mm)"),
15
- varSelectInput("yvar", "Y variable", df_num, selected = "Bill Depth (mm)"),
16
- checkboxGroupInput("species", "Filter by species",
17
- choices = unique(df$Species), selected = unique(df$Species)
18
  ),
19
- hr(), # Add a horizontal rule
20
- checkboxInput("by_species", "Show species", TRUE),
21
- checkboxInput("show_margins", "Show marginal plots", TRUE),
22
- checkboxInput("smooth", "Add smoother"),
23
- ),
24
- plotOutput("scatter")
 
 
 
 
 
 
 
 
25
  )
26
 
27
  server <- function(input, output, session) {
28
- subsetted <- reactive({
29
- req(input$species)
30
- df |> filter(Species %in% input$species)
31
  })
32
 
33
- output$scatter <- renderPlot(
34
- {
35
- p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
36
- theme_light() +
37
- list(
38
- theme(legend.position = "bottom"),
39
- if (input$by_species) aes(color = Species),
40
- geom_point(),
41
- if (input$smooth) geom_smooth()
42
- )
43
 
44
- if (input$show_margins) {
45
- margin_type <- if (input$by_species) "density" else "histogram"
46
- p <- p |> ggExtra::ggMarginal(
47
- type = margin_type, margins = "both",
48
- size = 8, groupColour = input$by_species, groupFill = input$by_species
49
- )
50
- }
51
 
52
- p
53
- },
54
- res = 100
55
- )
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  shinyApp(ui, server)
 
1
  library(shiny)
2
+ library(readxl)
3
+ library(dlookr)
4
+ library(rpivotTable)
5
+
6
+ ui <- fluidPage(
7
+ titlePanel("EDA no Browser rpivotTable + dlookr"),
8
+
9
+ sidebarLayout(
10
+ sidebarPanel(
11
+ h4("Dataset"),
12
+ p("Arquivo: STATUS1.xlsx"),
13
+
14
+ actionButton("diag", "Gerar diagnóstico dlookr")
 
 
 
15
  ),
16
+
17
+ mainPanel(
18
+ tabsetPanel(
19
+ tabPanel(
20
+ "Pivot Table",
21
+ rpivotTableOutput("pivot")
22
+ ),
23
+ tabPanel(
24
+ "Diagnóstico",
25
+ uiOutput("diag_ui")
26
+ )
27
+ )
28
+ )
29
+ )
30
  )
31
 
32
  server <- function(input, output, session) {
33
+
34
+ STATUS <- reactive({
35
+ read_excel("STATUS1.xlsx")
36
  })
37
 
38
+ output$pivot <- renderRpivotTable({
39
+ rpivotTable(STATUS())
40
+ })
 
 
 
 
 
 
 
41
 
42
+ observeEvent(input$diag, {
43
+
44
+ # Criar diretório www se não existir
45
+ if (!dir.exists("www")) {
46
+ dir.create("www")
47
+ }
 
48
 
49
+ diagnose_web_report(
50
+ STATUS(),
51
+ output_dir = "www",
52
+ output_file = "diagnostico.html"
53
+ )
54
+
55
+ output$diag_ui <- renderUI({
56
+ tags$iframe(
57
+ src = "diagnostico.html",
58
+ width = "100%",
59
+ height = "800px"
60
+ )
61
+ })
62
+ })
63
  }
64
 
65
  shinyApp(ui, server)