我想通过每次将其他变量作为输入来显示摘要并可视化回归模型。当代码工作时,我更改了列名iris
通过在数据集之间创建空格来获取数据集,现在我收到错误Error in parse: <text>:1:3: unexpected symbol
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyWidgets)
library(dplyr)
library(ggiraph)
library(ggiraphExtra)
library(plyr)
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(title = "Social Media Metrics", titleWidth = 320
),
sidebar = dashboardSidebar(width = 320,
uiOutput("value"),
uiOutput("value2")
),
body = dashboardBody(
verbatimTextOutput("plot"),
ggiraphOutput("plot2"),
plotOutput("plot3")
)
),
server = function(input, output) {
colnames(iris)[1:4]<-c("f f","s s","d d","f f f")
output$value<-renderUI({
pickerInput(
inputId = "val"
,
label = "DEPENDENT"
,
choices = colnames(iris)[-5] #all rows of selected column
,
multiple = F, options = list(`actions-box` = TRUE)
)
})
output$value2<-renderUI({
pickerInput(
inputId = "val2"
,
label = "INDEPENDENT"
,
choices = colnames(iris)[-5] #all rows of selected column
,
multiple =T, options = list(`actions-box` = TRUE)
)
})
model <- eventReactive(c(input$val,input$val2),{
req(c(input$val,input$val2))
lm(as.formula(paste(input$val," ~ ",paste(input$val2,collapse="+"))),data=iris)
})
output$plot <- renderPrint({
summary(model())
})
output$plot2 <- renderggiraph({
ggPredict(model(),se=TRUE,interactive=TRUE)
})
output$plot3<-renderPlot({
ggplot(iris,aes(y=input$val,x=input$val2))+geom_point()+geom_smooth(method="lm")
})
}
)