【发布时间】:2015-11-23 15:08:25
【问题描述】:
当我运行我的代码时,我没有收到任何错误并且我的应用程序保持运行状态(不会因为代码错误而变成灰屏)。但是,我的屏幕左侧没有任何输出。我假设我在某处有某种类型的语法错误,但我无法弄清楚。这是我的代码,应该很容易在您自己的 R Studio 上运行。
这是我的用户界面:
shinyUI(fluidPage(
titlePanel("Linear Regression"),
sidebarLayout(position = "right",
mainPanel(h2("Your Model"), dataTableOutput("table")),
sidebarPanel(h2("Your Data"),
fileInput("mydata", label = h4("Please upload the .xls, .txt, or.csv file you would like included in the analysis. Please use column names in your dataset.")),
textInput("response", label=h4 ("What is the column name of your response variable?")),
textInput("explan1", label=h4 ("What is the column name of your explanitory variable?")),
actionButton("analysis", "Analyze!"),
verbatimTextOutput("modelSummary"),
plotOutput("plot")
)
)
)
)
这是我的服务器:
shinyServer({
function(input, output) ({
observeEvent(input$analysis, {
reactive({
dat <- file.path(input$mydata)
response=input$response
explan1=input$explan1
plot(input$response~input$explan1, data=dat)
mean.response<-mean(dat$response,na.rm=T)
abline(h=mean.Premium)
model=lm(response~explan1, data = dat)
output$plot <- renderPlot({
plot(input$response~input$explan1, data= dat)
abline(model,col="red")
})
output$modelSummary <- renderPrint({
summary(model)
})
})
})
})
})
对于 renderText,我试图让它输出整个摘要。 谢谢!
【问题讨论】:
-
据我所知,您的应用程序运行正常。我可以在您的应用左侧看到所有菜单。如果您的意思是在您点击“分析”后出现问题,您可能应该制作一个最小的可重现示例(即不需要我们创建包含变量的文本文件以加载到您的应用中的示例)。