我创建了一个简单的闪亮应用。相关代码如下所示:
Server.R
library(shiny)
library(ggplot2)
shinyServer(function(input, output){
#Hier output je je plot, let op $myhist is iets wat je teruggeeft
output$myhist <- renderPlot({
df_graph <- df_test[df_test$playlist_name == input$var,]
#Dit is gewoon een normale graph aanmaken obv graph_data
g <- ggplot(df_graph, aes(x=key, y=value)) + geom_boxplot()
print(g)
})
})
UI.R
library(shiny)
shinyUI(fluidPage(
#maken sample data
#setwd("~/shiny_apps/echonest"),
df_test <- read.csv("df_echonest.csv", stringsAsFactors = F),
listIDs <- df_test$playlist_name,
#outlinen title
titlePanel(title = "This is the title"),
sidebarLayout(
sidebarPanel(
#Here you enter the var that you would like to use to filter the data shown in the graph
selectInput("var", "Select the eventID", choices = listIDs),
br(),
sliderInput("amount of fluctuation", "Integer:",
min=0, max=30, value=0)
),
mainPanel(("Personal information"),
plotOutput("myhist"))
)
))
运行应用程序所需的所有相关数据都存储在.csv文件中,该文件也放在同一文件夹中,并使用UI.R文件中的以下行加载:
df_test <- read.csv("df_echonest.csv", stringsAsFactors = F),
当我在本地运行时,一切顺利。但是,当我尝试使用闪亮部署它时,尝试访问相关页面(https://marcvanderpeet12.shinyapps.io/echonest/)I获取消息:
Personal information Error: object 'df_test' not found
虽然列表实际加载(并且该信息也来自df_test)。有什么想法会出错吗?
答案 0 :(得分:0)
尝试在server.R中导入df_echonest.csv,UI找到它但没有服务器端