My shiny app works locally but isnt works with the shared link

This is the link Posit Cloud. The app works well locally but not when I deploy it. There appear an image that says there is no content.

library(shiny)
library(readxl)
library(DT)
library(dplyr)

# Cargar el dataframe
df <- read_excel("/cloud/project/multiples_regresiones/results_1990_2020.xlsx")

# Cambiar nombres de las columnas
df <- df %>%
  rename(
    Año = Year,
    Hombres = Predicted_Hombres,
    Mujeres = Predicted_Mujeres
  )

# Crear conjunto de datos para la suma de la AMG
df_AMG <- df %>%
  group_by(Año, `Grupos quinquenales de edad`) %>%
  summarise(
    Hombres = sum(Hombres),
    Mujeres = sum(Mujeres),
    .groups = "drop"
  ) %>%
  mutate(Municipio = "AMG")

# Unir al conjunto de datos original
df <- bind_rows(df, df_AMG)

# Definir UI
ui <- fluidPage(
  titlePanel("Proyecciones de la población del AMG por grupos quinquenales de edad y sexo: 2025-2045"),
  
  sidebarLayout(
    sidebarPanel(
      selectInput("municipio", "Selecciona un Municipio:", choices = unique(df$Municipio)),
      selectInput("grupo", "Selecciona un Grupo de edad:", choices = unique(df$`Grupos quinquenales de edad`))
    ),
    
    mainPanel(
      h3("AMG"),
      DTOutput("totalAMG"),
      DTOutput("tableData")
    )
  )
)

# Definir server
server <- function(input, output, session) {
  
  total_AMG <- reactive({
    df %>%
      filter(Municipio == "AMG") %>%
      group_by(Año) %>%
      summarise(
        Hombres = sum(Hombres),
        Mujeres = sum(Mujeres),
        Total = Hombres + Mujeres,
        .groups = "drop"
      ) %>%
      mutate(
        Hombres = formatC(Hombres, format="f", big.mark=",", digits=0),
        Mujeres = formatC(Mujeres, format="f", big.mark=",", digits=0),
        Total = formatC(Total, format="f", big.mark=",", digits=0)
      )
  })
  
  filtered_data <- reactive({
    df %>%
      filter(Municipio == input$municipio, `Grupos quinquenales de edad` == input$grupo) %>%
      mutate(
        Total = Hombres + Mujeres,
        Hombres = formatC(Hombres, format="f", big.mark=",", digits=0),
        Mujeres = formatC(Mujeres, format="f", big.mark=",", digits=0),
        Total = formatC(Total, format="f", big.mark=",", digits=0)
      )
  })
  
  output$totalAMG <- renderDT({
    total_AMG()
  })
  
  output$tableData <- renderDT({
    filtered_data()
  })
  
}

# Lanzar la aplicación
shinyApp(ui, server)

I am tryng to deploy the app with posit cloud. Where is my error? It works locally. Thank you community.i have created many proects and all fails, but there is an app that work well, I need help to deploy my app.

Thank you.

Use a relative path (relative to the app's root folder) rather than an absolute path. When the app is deployed no longer has access to the project's file system.

Thank you, but didnt work.

Can you please clarify? Saying "it didn't work" doesn't give us any information to work with. Do you get any error message?

I get a like a blank page with the message "No content", but files are in the directory.

Thank you

Sorry but you are not providing enough information for us to be able to address your problem. The only evident issue was the use of an absolute path in your code, beyond that I can only speculate, maybe you are not deploying the necessary files along with the app or you are not using the required naming convention for the main app file.

I can answer you about how I am doing the things. Ask me and I can give you more information about how I am doing the things. Thank you.

How are you trying to deploy the app? please try to provide a detailed step by step descripcion and maybe a link to your project (if possible).

The link Is in the top of this conversation.

  1. I use rsconnect yo add the token, secret, Sever.
  2. Set the directory where I have the code.
  3. Run the code.
  4. rsconnect:: deployapp()

It works but only locally.

I have tried to post the link but appears a message that says I cant post the link yo you again.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.