首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在shiny-server上使用shinylogs中的store_json()时出现问题

在shiny-server上使用shinylogs中的store_json()时出现问题
EN

Stack Overflow用户
提问于 2020-05-11 18:36:21
回答 1查看 54关注 0票数 0

我正在尝试将一个使用shinylogs store_json()-function的闪亮应用部署到运行在ubuntu20.04上的闪亮服务器上。但是,无论我使用哪个路径,它都不会保存文件,我的日志中也不会出现错误。

使用write.table()一切都很好,所以我想知道shinylogs是否需要在shiny-server上运行任何特殊的配置。

我引用了来自https://github.com/dreamRs/shinylogs/blob/master/examples/store_json.R的最小工作示例。该应用程序执行正常,我可以尝试它,但它不会保存任何日志。

因为我想部署的应用程序不是我写的,所以我在某种程度上依赖于使用shinylogs,所以我非常感谢任何帮助!

代码语言:javascript
复制
  library(shiny)
  library(shinylogs)

  tmp <- "~"

  # Classir Iris clustering with Shiny
  ui <- fluidPage(

    headerPanel("Iris k-means clustering"),

    sidebarLayout(
      sidebarPanel(
        selectInput(
          inputId = "xcol",
          label = "X Variable",
          choices = names(iris)
        ),
        selectInput(
          inputId = "ycol",
          label = "Y Variable",
          choices = names(iris),
          selected = names(iris)[[2]]
        ),
        numericInput(
          inputId = "clusters",
          label = "Cluster count",
          value = 3,
          min = 1,
          max = 9
        )
      ),
      mainPanel(
        plotOutput("plot1")
      )
    )
  )

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

    # Store JSON with logs in the temp dir
    track_usage(
      storage_mode = store_json(path = tmp)
    )

    # classic server logic

    selectedData <- reactive({
      iris[, c(input$xcol, input$ycol)]
    })

    clusters <- reactive({
      kmeans(selectedData(), input$clusters)
    })

    output$plot1 <- renderPlot({
      palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
                "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))

      par(mar = c(5.1, 4.1, 0, 1))
      plot(selectedData(),
           col = clusters()$cluster,
           pch = 20, cex = 3)
      points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
    })

  }

  shinyApp(ui, server)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-11 19:55:31

我设法通过简单地引入library(jsonlite)解决了这个问题,因为它的write_json()函数是由使用::的shinylog调用的。不过,我真的没有一个解释。所以,如果有人知道这为什么会出问题,请让我知道!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61727673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档