Skip to content

Can support running shiny app? #13

Description

@bianchenhao

claude code cli:

❯ run  #                                                                                                                                                              
  # This is a Shiny web application. You can run the application by clicking                                                                                         
  # the 'Run App' button above.                                                                                                                                          
  #                                                                                                                                                                    
  # Find out more about building applications with Shiny here:                                                                                                           
  #                                                                                                                                                                    
  #    https://shiny.posit.co/                                                                                                                                       
  #                                                                                                                                                                  
                                                                                                                                                                     
  library(shiny)                                                                                                                                                     
                                                                                                                                                                     
  # Define UI for application that draws a histogram                                                                                                                 
  ui <- fluidPage(                                                                                                                                                   
                                                                                                                                                                     
      # Application title                                                                                                                                            
      titlePanel("Old Faithful Geyser Data"),                                                                                                                        
                                                                                                                                                                     
      # Sidebar with a slider input for number of bins                                                                                                               
      sidebarLayout(                                                                                                                                                 
          sidebarPanel(                                                                                                                                              
              sliderInput("bins",                                                                                                                                    
                          "Number of bins:",                                                                                                                         
                          min = 1,                                                                                                                                   
                          max = 50,                                                                                                                                  
                          value = 30)                                                                                                                                
          ),                                                                                                                                                         
                                                                                                                                                                     
          # Show a plot of the generated distribution                                                                                                                
          mainPanel(                                                                                                                                                 
             plotOutput("distPlot")                                                                                                                                  
          )                                                                                                                                                          
      )                                                                                                                                                              
  )                                                                                                                                                                  
                                                                                                                                                                     
  # Define server logic required to draw a histogram                                                                                                                 
  server <- function(input, output) {                                                                                                                                
                                                                                                                                                                     
      output$distPlot <- renderPlot({                                                                                                                                
          # generate bins based on input$bins from ui.R                                                                                                              
          x    <- faithful[, 2]                                                                                                                                      
          bins <- seq(min(x), max(x), length.out = input$bins + 1)                                                                                                   
                                                                                                                                                                     
          # draw the histogram with the specified number of bins                                                                                                     
          hist(x, breaks = bins, col = 'darkgray', border = 'white',                                                                                                 
               xlab = 'Waiting time to next eruption (in mins)',                                                                                                     
               main = 'Histogram of waiting times')                                                                                                                  
      })                                                                                                                                                             
  }                                                                                                                                                                  
                                                                                                                                                                     
  # Run the application                                                                                                                                              
  shinyApp(ui = ui, server = server)                                                                                                                                 
                                                                                                                                                                     

● r-studio - execute_r (MCP)(code: "library(shiny)\n\n# Define UI for application that draws a histogram\nui <- fluidPage(\n    titlePanel(\"Old Faithful Geyser
                            Data\"),\n    sidebarLayout(\n        sidebarPanel(\n            sliderInput(\"bins\",\n                        \"Number of bins:\",\n
                                             min = 1,\n                        max = 50,\n                        value = 30)\n        ),\n        mainPanel(\n          
                             plotOutput(\"distPlot\")\n        )\n    )\n)\n\n# Define server logic required to draw a histogram\nserver <- function(input, output) {\n
                              output$distPlot <- renderPlot({\n        x    <- faithful[, 2]\n        bins <- seq(min(x), max(x), length.out = input$bins + 1)\n         
                            hist(x, breaks = bins, col = 'darkgray', border = 'white',\n             xlab = 'Waiting time to next eruption (in mins)',\n             main
                             = 'Histogram of waiting times')\n    })\n}\n\n# Run the application\nshinyApp(ui = ui, server = server)")                                   
  ⎿  R Error: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.     

I Started service in Rstudio-server docker, session info:

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] ClaudeR_0.2.0 shiny_1.11.1 

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       cli_3.6.5         rlang_1.1.6      
 [4] promises_1.3.3    generics_0.1.4    xtable_1.8-4     
 [7] jsonlite_2.0.0    glue_1.8.0        colorspace_2.1-0 
[10] htmltools_0.5.8.1 httpuv_1.6.13     sass_0.4.9       
[13] scales_1.3.0      grid_4.3.2        jquerylib_0.1.4  
[16] munsell_0.5.0     tibble_3.3.0      fastmap_1.2.0    
[19] base64enc_0.1-3   lifecycle_1.0.4   memoise_2.0.1    
[22] compiler_4.3.2    miniUI_0.1.1.1    dplyr_1.1.4      
[25] Rcpp_1.1.0        pkgconfig_2.0.3   rstudioapi_0.17.1
[28] later_1.4.2       digest_0.6.34     R6_2.6.1         
[31] tidyselect_1.2.1  pillar_1.11.0     magrittr_2.0.3   
[34] bslib_0.8.0       tools_4.3.2       gtable_0.3.4     
[37] mime_0.13         cachem_1.1.0      ggplot2_3.5.2 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions