闪亮的应用错误:发布到闪亮的io时找不到数据对象

时间:2019-08-08 22:00:46

标签: r shiny

在将我的第一个闪亮应用程序加载到Shinyapps.io Web服务器时遇到问题。

该应用在本地运行正常,但是当我将其上传到Shinyapps.io时,它会发送“找不到对象错误消息”。

在Google工作了几个小时后,我尝试了不同的应用程序和方法,但没有成功:

包括将数据放入mydata <- "./data/mydata.csv"

的建议

how to deploy shiny app that uses local data

这是一个非常简单的闪亮应用程序形式的Shiny gallery。要使其完全可复制,您只需要在本地系统中将虹膜数据集保存到CSV中即可。然后将以下代码用于闪亮的应用程序:

library(shiny)

fluidPage(pageWithSidebar(
    headerPanel('Iris k-means clustering'),
    sidebarPanel(
        selectInput('xcol', 'X Variable', names(myiris)),
        selectInput('ycol', 'Y Variable', names(myiris)),
        numericInput('clusters', 'Cluster count', 2,
                     min = 1, max = 9)
    ),
    mainPanel(
        plotOutput('plot1')
    )
)
)

library(shiny)

myiris <- read.csv("./myiris.csv")

function(input, output, session) {

    selectedData <- reactive({

        myiris[, 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)
    })

}

应用程序生成的错误消息:

ERROR: An error has occurred. Check your logs or contact the app author for clarification.

日志中的错误消息:

Warning: Error in lapply: object 'myiris' not found

我在Windows中使用R

提前谢谢!

0 个答案:

没有答案