Error when deploying Shiny App

Hi, I got this error in R console when I try to deploy a Shiny App:

Error in ``` `$<-.data.frame`(`*tmp*`, "config_url", value = "https://www.shinyapps.io/admin/#/application/") : 
  replacement has 1 row, data has 0```

My code is this:

   library(shiny)
   library(rvest)
   library(plotly)
   library(ggplot2)

dades <- read.csv('valor_jugadores2.csv', header = TRUE, sep = ";", stringsAsFactors = F)

dades$Fecha <- as.Date(dades$Fecha,"%d/%m/%Y")
dades<-dades[order(dades$Jugador,decreasing = F),]

data<-levels(as.factor(dades$Equipo))
jugadors<-levels(as.factor(dades$Jugador))
equipo<-levels(as.factor(dades$Equipo))
plataforma<-levels(as.factor(dades$Plataforma))
valor<-levels(as.factor(dades$Valor))

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(  
      selectInput("Plataforma","Selecciona Plataforma", plataforma),
      selectInput("Equipo", "Selecciona Equipo", equipo),
      selectInput("Jugador","Selecciona Jugador", jugadors)
    ),
    mainPanel(plotlyOutput("result"))
  )
)

server <- function(session,input, output) {
  
  observe({
    firstfilter <- dades %>% filter(Plataforma == input$Plataforma) %>% select(Equipo)
    updateSelectInput(session,"Equpio", "Selecciona Equipo", choices = unique(firstfilter))
  })
  
  observe({
    secondfilter <- dades$Jugador[dades$Equipo == input$Equipo & dades$Plataforma == input$Plataforma]
    updateSelectInput(session,"Jugador","Selecciona Jugador", choices = unique(secondfilter))
  })
  
  output$result<-renderPlotly({
    dades_graf <- dades[which(dades$Plataforma==input$Plataforma & dades$Jugador==input$Jugador),]
    p <-plot_ly(data=dades_graf, x= dades_graf$Fecha, y= dades_graf$Valor, type = 'scatter', mode = 'lines+markers') %>% 
    
      layout(separators= ",.",
             autosize = TRUE,
             title="Valor Jugadores", 
             xaxis=list(title="Fecha"),
             yaxis=list(title="Valor", tickformat= ",d"))
              })
}

And the browser shows me this:

image

Can you help me please?

Thank you!! :slight_smile:

if you can run

dades <- read.csv('valor_jugadores2.csv', header = TRUE, sep = ";", stringsAsFactors = F)
dput(head(dades))

then we could have a few records from dades and try to run your code and deploy it.
my suspicion is the csv has encoding issue

@nirgrahamuk thanks for your answer. I test it and this error has disappeared from my console, but I still have the browser problem

I don't know what you think I asked you to do that would change anything for how your application logs on the console so that it would disappear....

Theres no way I could help you without your data.

Hi, my csv has 25500 rows, and i havn't share here because i can't upload files with format like csv. How can I share it with you?

If your file had fewer rows, would it run and give the same error?

Ok, here is:

Plataforma;Fecha;Jugador;Valor;PosiciĂłn;Equipo
PC;11/04/2020;Ezkieta;160000;Portero;Athletic Club
PC;11/04/2020;HerrerĂ­n;230000;Portero;Athletic Club
PC;11/04/2020;Unai SimĂłn;2310000;Portero;Athletic Club
PC;11/04/2020;Balenziaga;230000;Defensa;Athletic Club
PC;11/04/2020;Capa;3690000;Defensa;Athletic Club
PC;11/04/2020;De Marcos;260000;Defensa;Athletic Club
PC;11/04/2020;Iñigo Martínez;4440000;Defensa;Athletic Club
PC;11/04/2020;Lekue;320000;Defensa;Athletic Club
PC;11/04/2020;Unai NĂșñez;700000;Defensa;Athletic Club
PC;11/04/2020;Yeray Álvarez;3980000;Defensa;Athletic Club
PC;11/04/2020;Yuri Berchiche;5450000;Defensa;Athletic Club
PC;11/04/2020;Beñat;270000;Centrocampista;Athletic Club
PC;11/04/2020;Dani GarcĂ­a;1690000;Centrocampista;Athletic Club
PC;11/04/2020;Gaizka Larrazabal;240000;Centrocampista;Athletic Club
PC;11/04/2020;Ibai GĂłmez;550000;Centrocampista;Athletic Club
PC;11/04/2020;ĂĂ±igo CĂłrdoba;560000;Centrocampista;Athletic Club
PC;11/04/2020;Mikel San José;290000;Centrocampista;Athletic Club
PC;11/04/2020;Mikel Vesga;400000;Centrocampista;Athletic Club
PC;11/04/2020;Muniain;5630000;Centrocampista;Athletic Club
PC;11/04/2020;RaĂșl GarcĂ­a;6250000;Centrocampista;Athletic Club
PC;11/04/2020;Sancet;280000;Centrocampista;Athletic Club
PC;11/04/2020;Unai LĂłpez;890000;Centrocampista;Athletic Club
PC;11/04/2020;Unai Vencedor;280000;Centrocampista;Athletic Club
PC;11/04/2020;Aduriz;740000;Delantero;Athletic Club
PC;11/04/2020;Guruzeta;190000;Delantero;Athletic Club
PC;11/04/2020;Kodro;450000;Delantero;Athletic Club
PC;11/04/2020;Villalibre;720000;Delantero;Athletic Club
PC;11/04/2020;Williams;8100000;Delantero;Athletic Club
PC;11/04/2020;Adån;160000;Portero;Atlético de Madrid
PC;11/04/2020;Oblak;3760000;Portero;Atlético de Madrid
PC;11/04/2020;Arias;420000;Defensa;Atlético de Madrid
PC;11/04/2020;Carlos Isaac;190000;Defensa;Atlético de Madrid
PC;11/04/2020;Felipe;4080000;Defensa;Atlético de Madrid
PC;11/04/2020;José Giménez;1910000;Defensa;Atlético de Madrid
PC;11/04/2020;Manu Sånchez;270000;Defensa;Atlético de Madrid
PC;11/04/2020;Mario Hermoso;590000;Defensa;Atlético de Madrid
PC;11/04/2020;Renan Lodi;2240000;Defensa;Atlético de Madrid
PC;11/04/2020;Savic;1130000;Defensa;Atlético de Madrid
PC;11/04/2020;Solano;200000;Defensa;Atlético de Madrid
PC;11/04/2020;Trippier;3490000;Defensa;Atlético de Madrid
PC;11/04/2020;Vrsaljko;840000;Defensa;Atlético de Madrid
PC;11/04/2020;Vitolo;1500000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Carrasco;1820000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Correa;3910000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Germån Valera;220000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Héctor Herrera;1120000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Koke;7880000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Lemar;620000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Marcos Llorente;2450000;Centrocampista;Atlético de Madrid
PC;11/04/2020;Rodrigo Riquelme;210000;Centrocampista;Atlético de Madrid
PC;11/04/2020;SaĂșl Ñíguez;6800000;Centrocampista;AtlĂ©tico de Madrid

I believe the problem is file encoding of the csv.
the csv should be in UTF-8.
if you have the data.frame nice , then use the fileencoding when you save it so that it has the correct encoding.
for example if it was called dades and you save the dades csv to read in later in the shiny app then use

write.csv(dades,"dades3.csv",fileEncoding = 'UTF-8')

Hi @nirgrahamuk now it's working well. Thanks for your help, for dedicate your time on it . Very thankful.

1 Like