gpt4 book ai didi

r - 使用 dygraphs 部署 r shiny 应用程序时遇到问题

转载 作者:行者123 更新时间:2023-12-02 04:29:59 25 4
gpt4 key购买 nike

我目前正在尝试将使用 dygraphs 包的 R shiny 应用程序部署到 shinyapps.io。我的应用程序在本地运行良好,但当我尝试部署时,它说无法找到该网页 - “HTTP 500 内部服务器错误”。我的用户界面代码是:

shinyUI(fluidPage(

titlePanel("MyApp"),

fluidRow(
column(12,
p("Info Text")
,dygraphOutput("plot")
)
)
))

服务器代码是:

shinyServer(function(input, output) {
library(shiny)
library(dygraphs)



output$plot<- renderDygraph({
data <- read.csv("data.csv", header=TRUE, sep =",",na.strings="-")
dygraph(data, main = "Plot") %>%
dyLegend(width = 170 ,
labelsSeparateLines = TRUE ,
show = "always") %>%
dyOptions(stackedGraph = FALSE)

当我从 UI 代码中删除 dygraphOutput 函数时,应用程序部署成功。有没有人遇到过类似的问题?

最佳答案

对我来说一切正常,我认为问题出在您的 csv 文件上。您可以看到我的应用程序使用此代码运行良好:

服务器

library(shiny)
library(dygraphs)

shinyServer(function(input, output,session) {

data <- readRDS("data.rds")

output$plot<- renderDygraph({
req(data)
dygraph(data, main = "Plot") %>% dyLegend(width = 170 , labelsSeparateLines = TRUE , show = "always") %>%dyOptions(stackedGraph = FALSE)
})

})

界面

rm(list = ls())
library(shiny)
library(dygraphs)

ui <- fluidPage(
titlePanel("MyApp"),
fluidRow(
column(12,p("Info Text"),dygraphOutput("plot"))
)
)

文件夹结构

enter image description here

最终输出

enter image description here

在 aws 上托管的应用

http://52.39.186.219:3838/Dygraphs/

关于r - 使用 dygraphs 部署 r shiny 应用程序时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49856837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com