posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
151 stars 16 forks source link

Error loading packages #37

Closed clementrx closed 9 months ago

clementrx commented 9 months ago

Hi !

For context, I'm using shinylive with github to deploy my .html.

For some packages (highcharter, plotly) when I'm using them the page doesn't load. Moreover, when I'm trying on Shiny Editor, I have the message :

Downloading webR package: plotly Error: could not find function "plotlyOutput" Error: attempt to apply non-function

Is there a specific procedure for using certain packages? And if so is it possible to add it to the documentation with an example?

Thanks

schloerke commented 9 months ago

Can you paste your app code below so that I may hopefully reprex the behavior on my side?

clementrx commented 9 months ago

Hi ! This is an example :

# libs
library(shiny)
library(highcharter)

# (UI)
ui <- fluidPage(
  titlePanel("Exemple"),

  sidebarLayout(
    sidebarPanel(
      # Input: Slider for the number of points
      sliderInput("n_points", "Nombre de points :", 
                  min = 10, max = 100, value = 50)
    ),

    # Main
    mainPanel(
      # Output: Highcharter scatter plot
      highchartOutput("scatter_chart")
    )
  )
)

#  server
server <- function(input, output) {

  data <- reactive({
    set.seed(123)  # Pour la reproductibilité
    x <- rnorm(input$n_points)
    y <- x + rnorm(input$n_points)
    data.frame(x = x, y = y)
  })

  output$scatter_chart <- renderHighchart({
    highchart() %>%
      hc_chart(type = "scatter") %>%
      hc_title(text = "Scatter Plot with Highcharter") %>%
      hc_xAxis(title = list(text = "X-axis")) %>%
      hc_yAxis(title = list(text = "Y-axis")) %>%
      hc_add_series(data = data(), type = "scatter", hcaes(x, y), name = "Points")
  })
}

shinyApp(ui, server)

Error message : Error: package or namespace load failed for ‘highcharter’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘igraph’

schloerke commented 9 months ago

Thank you for the app code!


Ah. So your app is getting caught by shinylive/webr's capabilities.

List of packages that webr (which posit-dev/r-shinylive uses to load packages) supports: https://repo.r-wasm.org/ Screenshot: Screenshot 2023-12-01 at 4 32 07 PM

{igraph} is one of the packages (like {curl} or {XML}) that is having trouble compiling for WebAssembly.

We do not have a known timeline (if at all) of when these missing packages will become available.


Closing