0
我一直为此而沮丧,我没有得到到能出现趋势线:R闪亮的ggplot2支持向量机趋势线
library(shiny)
ui = pageWithSidebar(
headerPanel("Twitter Engagement Correlations"),
sidebarPanel(
selectInput("c", label = "Variable:",
choices = colnames(dataset))
),
mainPanel(
plotOutput('plot1')
)
)
server = function(input, output) {
reactive({
library(e1071)
regressor = svm(Engagements ~ Character.count,
data = dataset,
type = 'eps-regression')
})
output$plot1 = renderPlot({
print(ggplot() +
geom_point(aes(x = dataset[,input$c], y = dataset$Engagements),
colour = 'red') +
geom_line(aes(x = dataset$Character.count, y = predict(regressor, newdata = dataset)),
colour = 'blue') +
ggtitle('SVR Regression Model') +
xlab(input$c) +
ylab('Engagements'))
})
}
shinyApp(ui = ui, server = server)
错误代码“对象‘回归’找不到”出现,我不知道如何解决? 在此先感谢您的帮助