R 为什么我的应用程序只能在本地运行,而不能在shinyapps.io上运行?
我正试图在shinyapps.io上部署我的闪亮应用程序,我收到以下消息: “发生了一个错误 应用程序启动失败(已退出,代码为1)。” 我试图提交setwd行和其他东西,但我没有找到解决方案 问题可能是文件路径错误?我应该将“read.csv”行放入我的服务器或ui函数中吗 这是我的密码:R 为什么我的应用程序只能在本地运行,而不能在shinyapps.io上运行?,r,shiny,R,Shiny,我正试图在shinyapps.io上部署我的闪亮应用程序,我收到以下消息: “发生了一个错误 应用程序启动失败(已退出,代码为1)。” 我试图提交setwd行和其他东西,但我没有找到解决方案 问题可能是文件路径错误?我应该将“read.csv”行放入我的服务器或ui函数中吗 这是我的密码: #setwd(dir = "/media/miles/MILES/Projets & Cours/Master_1/Semestre 2/lardjane/Shiny_app/Projet Shiny
#setwd(dir = "/media/miles/MILES/Projets & Cours/Master_1/Semestre 2/lardjane/Shiny_app/Projet Shiny")
matches <- read.csv('./matches.csv', stringsAsFactors=FALSE, sep=",", header=TRUE)
matches <- matches[,c(3,6)]
#summary(matches)
matches$platformid <- as.factor(matches$platformid)
#levels(matches$platformid)
#install.packages('shiny')
library(shiny)
#install.packages('rsconnect')
library(rsconnect)
ui <- shinyUI(fluidPage(
# Give the page a title
titlePanel("Game time by server"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
selectInput("region", "Server:",
choices=levels(matches$platformid)),
hr(),
selectInput(inputId = "n_breaks",
label = "Number of bins in histogram (approximate):",
choices = c(10, 20, 35, 50),
selected = 20),
hr(),
checkboxInput(inputId = "individual_obs",
label = strong("Show individual observations"),
value = FALSE),
checkboxInput(inputId = "density",
label = strong("Show density estimate"),
value = FALSE),
conditionalPanel(condition = "input.density == true",
sliderInput(inputId = "bw_adjust",
label = "Bandwidth adjustment:",
min = 0.2, max = 2, value = 1, step = 0.2)),
hr(),
helpText("Data from Kaggle (2014-2018) League of Legends Ranked Matches.")
),
# Create a spot for the barplot
mainPanel(
plotOutput("timePlot")
)
)
)
)
server <- function(input, output) {
# Fill in the spot we created for a plot
output$timePlot <- renderPlot({
# Render a histogramme
hist(matches[matches$platformid==input$region,2],
probability = TRUE,
breaks = as.numeric(input$n_breaks),
main = "Game Time",
ylab="",
xlab="Duration (seconds)")
if (input$individual_obs) {
rug(matches[matches$platformid==input$region,2])
}
if (input$density) {
dens <- density(matches[matches$platformid==input$region,2],
adjust = input$bw_adjust)
lines(dens, col = "blue")
}
})
}
shinyApp(ui = ui, server = server)
#setwd(dir=“/media/miles/miles/Projets&Cours/Master_1/Semestre 2/lardjane/shinny_app/Projet shinny”)
匹配swd不是解决这一问题的方法,因为在Shiny(以及一般的R)中环境是如何工作的。当您启动Shining时,您实际上不知道您的Shining服务器运行在哪个物理服务器上。因此,您需要使用通用解决方案
试试这个:
matches <- read.csv('./matches.csv',
stringsAsFactors=FALSE, sep=",", header=TRUE)
matchesswd不是解决这个问题的方法,因为在Shiny(以及一般的R)中环境是如何工作的。当您启动Shining时,您实际上不知道您的Shining服务器运行在哪个物理服务器上。因此,您需要使用通用解决方案
试试这个:
matches <- read.csv('./matches.csv',
stringsAsFactors=FALSE, sep=",", header=TRUE)
匹配每个,如果csv文件与应用程序位于同一位置,请尝试:
匹配每个,如果csv文件与应用程序位于同一位置,请尝试:
匹配项请不要使用图像。。将信息复制并粘贴到问题中。您不应该在Shiny或任何脚本中使用swd()。我发现如何使用showcase模式显示代码。请不要使用图像。。将信息复制并粘贴到问题中。您不应该在Shiny或任何脚本中使用swd()。我发现如何使用showcase模式显示代码。我尝试了您的解决方案,但仍然存在相同的问题。它尝试了其他方法,我收到了以下消息:“路径应指向项目目录中的文件”。看起来我使用了错误的目录地址。感谢您提供的解决方案。我尝试了您的解决方案,但仍然存在相同的问题。它尝试了其他方法,我收到以下消息:“路径应指向项目目录中的文件”。看起来我使用了错误的目录地址。感谢您提供的解决方案。第一个解决方案很好,但我已将您的解决方案添加到我的代码中。我也非常感谢您。第一个解决方案很好,但我将您的解决方案添加到了我的代码中。我也非常感谢你。