3

I got a Shiny App that works fine on my PC, but once I deploy on shinyapps.io it shows the following error on the web browser:

enter image description here

And the following error on the Deployment Console:

Warning message:
In value[[3L]](cond) :
  Failed to parse 
C:/Users/david.jorquera/AppData/Local/Temp/RtmpSOqdYV/file13849671673/app.R 
; dependencies in this file will not be discovered.

If you need the exact excel file I'm using I would happily attach it if you tell me how to do it (sorry, haven't figure that out yet). Here is the UI:

library(shiny)
library(ggplot2)
library(dplyr)
library(readxl)

EPA <- read_excel("data/EPA.xlsx")


ui <- fluidPage(titlePanel(img(src = 'logo-escudo-rojo.jpg', height=100, 
width=150)),
            titlePanel("Dirección de Análisis Institucional"),

sidebarLayout(
sidebarPanel(selectInput("facultad", h4("Seleccione Facultad o Total UDP"),
                     choices=c("Arquitectura, Arte y Diseño",
                                  "Ciencias Sociales e Historia",
                                  "Comunicación y Letras",
                                  "Derecho",
                                  "Economía y Empresa",
                                  "Educación",
                                  "Ingeniería y Ciencias", 
                                  "Medicina",
                                  "Psicología",
                                  "Salud y Odontología",
                                  "Total UDP")),
conditionalPanel(condition = "input.facultad=='Arquitectura, Arte y 
Diseño'",
             selectInput("faad", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Arquitectura",
                                       "Artes Visuales",
                                       "Diseño",
                                       "Facultad de Arquitectura, Arte y Diseño"), selected="Arquitectura")),
conditionalPanel(condition = "input.facultad=='Ciencias Sociales e Historia'",
             selectInput("fcsh", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Bachillerato en Ciencias Sociales y Humanidades",
                                       "Ciencia Política",
                                       "Historia",
                                       "Sociología",
                                       "Facultad de Ciencias Sociales e Historia"), selected="Bachillerato en Ciencias Sociales y Humanidades")),
conditionalPanel(condition = "input.facultad=='Comunicación y Letras'",
             selectInput("fcyl", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Literatura Creativa",
                                       "Periodismo",
                                       "Publicidad",
                                       "Facultad de Comunicación y Letras"))),
conditionalPanel(condition = "input.facultad=='Economía y Empresa'",
             selectInput("fee", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Ingeniería Comercial",
                                       "Ingeniería en Control de Gestión",
                                       "Contador Auditor-Contador Público 
(D)",
                                       "Facultad de Economía y Empresa"))),
conditionalPanel(condition = "input.facultad=='Educación'",
             selectInput("fed", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Pedagogía Básica",
                                       "Pedagogía Parvularia",
                                       "Pedagogía en Educación Diferencial",
                                       "Pedagogía en Inglés",
                                       "Pedagogía Media en Lenguaje y 
Comunicación",
                                       "Pedagogía Media en Historia y 
Ciencias Sociales",
                                       "Facultad de Educación"))),
conditionalPanel(condition = "input.facultad=='Ingeniería y Ciencias'",
             selectInput("fing", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Ingeniería Civil Plan Común",
                                       "Ingeniería Civil Industrial",
                                       "Ingeniería Civil en Informática y 
Telecomunicaciones",
                                       "Ingeniería Civil en Obras Civiles",
                                       "Facultad de Ingeniería y 
Ciencias"))),
conditionalPanel(condition = "input.facultad=='Salud y Odontología'",
             selectInput("fsyod", h4("Seleccione carrera o Total Facultad"),
                          choices=c("Enfermería",
                                       "Kinesiología",
                                       "Odontología",
                                       "Obstetricia y Neonatología",
                                       "Tecnología Médica",
                                       "Facultad de Salud y 
Odontología")))),

  mainPanel(h4("Encuesta de Primer Año"),


plotOutput("grafico1"),
br(),
br(),
plotOutput("grafico2")


)
))

...And here is the Server

server <- function(input, output) {


base <- reactive ({

base <-   if(input$facultad == "Arquitectura, Arte y Diseño") {
      filter(EPA, Carrera==input$faad)}
   else 
     if(input$facultad == "Ciencias Sociales e Historia") {
     filter(EPA, Carrera==input$fcsh)}
   else
     if(input$facultad == "Comunicación y Letras") {
   filter(EPA, Carrera==input$fcyl)}  
   else
     if(input$facultad == "Derecho") {
       filter(EPA, Carrera == "Facultad de Derecho")}
    else
   if(input$facultad == "Economía y Empresa") {
     filter(EPA, Carrera == input$fee)}
   else
   if(input$facultad == "Educación") {
     filter(EPA, Carrera == input$fed)}
 else
   if(input$facultad == "Ingeniería y Ciencias") {
     filter(EPA, Carrera == input$fing)}
 else
   if(input$facultad == "Medicina") {
     filter(EPA, Carrera == "Facultad de Medicina")}
 else
   if(input$facultad == "Psicología") {
     filter(EPA, Carrera == "Facultad de Psicología")}
 else
   if(input$facultad == "Salud y Odontología") {
     filter(EPA, Carrera == input$fsyod)}


  }) 


  output$grafico1 <- renderPlot({

datos <- base()

    ggplot(datos, aes(Año, EPA_T_2, label=paste(round(EPA_T_2*100, 0), "%", 
sep="")))  + 
      geom_col(aes(y = EPA_T_2)) + 
      scale_x_continuous(name = "Cohorte de Ingreso", 
                         breaks = seq(min(datos[[4]]), max(datos[[4]]), 1)) 
+
      scale_y_continuous(name = "% de Estudiantes encuestados", labels = 
scales::percent) +
      geom_text(position = position_stack(vjust=0.5), size=5) +
      ggtitle("Tasa de Respuesta Encuesta de Primer Año") + 
theme(plot.title=
           element_text(color="#666666", face="bold", size=20, hjust=0.5))

  })



output$grafico2 <- renderPlot({

datos <- base()

ggplot(datos, aes(Año, EPA_T_1_OK, label=EPA_T_1_OK)) +
  geom_col(aes(y = EPA_T_1_OK)) +
  scale_x_continuous(name = "Cohorte de Ingreso", 
                     breaks = seq(min(datos[[4]]), max(datos[[4]]), 1)) +
  scale_y_continuous(name = "N° de Estudiantes encuestados", breaks = 
seq(min(0), max(datos[[6]]+10), 20)) +
  geom_text(position = position_stack(vjust=0.5), size=5) +
  ggtitle("Número de Estudiantes Encuestados") + theme(plot.title=
          element_text(color="#666666", face="bold", size=20, hjust=0.5))


})  

  }

shinyApp(ui = ui, server = server)

I've seen this question presented before and one solution was related to replacing library() for require(), but this has not resolved the issue.

Axeman
  • 32,068
  • 8
  • 81
  • 94
David Jorquera
  • 2,046
  • 12
  • 35
  • 2
    Smells like an encoding issue. See https://github.com/rstudio/packrat/issues/285 – greg L Jan 19 '18 at 02:01
  • its you;re library issue, I had the same with `Rcpp` mix up. So I re-installed R and Shiny Server and only installed packages as superuser – Pork Chop Jan 19 '18 at 07:49
  • It's not any of the above. I've tried different encodings and tried on a different computer with superuser profile. The example app on the shinyapps guide (with old faithful data) uploads fine, so I don't know what could be it! I'm losing it!! – David Jorquera Jan 20 '18 at 21:09

2 Answers2

3

After days of trying different solutions, it turns out IT WAS a problem related to encoding. Te solution however wasn't on trying enconding specifications inside the code (I tried saving with UTF-8 my app and my database, using enc2utf8() and other related functions; revisiting similar issues on this webpage, etc). Finally, it turns out that the Server was making calls to values inside the database that were full of special characters (mostly ñ and accent marks). So the solution was to replace those calls for calls on values instead of strings. I only wish someone would told me that sooner! but anyway, live and learn.

David Jorquera
  • 2,046
  • 12
  • 35
  • Awesome! I was so frustrated. My issue was that I was using an accent in the `expression()` function. What I did was replacing this with the `latex2exp::TeX()` function which recieved a string. Also, I was using inside variables In the output and input such as `output$gráfica` and it worked by replacing `output$grafica` or `output$\`gráfica\`` – Edgar Alarcón Jan 01 '21 at 17:32
1

I was struggling with a same issue for a few weeks ago and whenever I searched for a solution, this question you made here appeared. I finally was able to deploy my shinny app by writing the variables names between '' The problem was that my shinny couldn't find variables such us GÉNERO or DÍA when trying to deploy it, so I started to put those between backticks like `DÍA` and `GÉNERO` (after re writing it from 0). I wanted to let this workaround written somewhere and this question seems to be the best place. Regards from Argentina!

margusl
  • 7,804
  • 2
  • 16
  • 20
  • Hola Joaquín, gracias por la respuesta. La verdad es que después de años de experiencia, ahora nunca llamaría a las variables con tildes o caracteres especiales. Esas cosas pueden ir en las etiquetas, que aguantan todo, pero para variables y objetos del sistema, es mejor nombres alfanuméricos sencillos (de todas formas, si tengo que hacerlo, las encierro en el backquote "`" y ya está). También miro el código de mi pregunta y me horroriza, pero creo que es mejor dejarla porque sé que no soy el único que se ha encontrado con este problema. Saludos from Chile! – David Jorquera Jun 23 '22 at 21:31