【发布时间】:2022-02-03 15:34:12
【问题描述】:
我尝试用 Shiny 编写一个简单的应用程序。下面是ui.R
library(shiny)
library(ggplot2)
shinyUI(fluidPage(
titlePanel("Explore mtcars dataset"),
sidebarLayout(
sidebarPanel(
selectInput("inputDF","Enter Y to plot vs mpg",choices = c('wt','disp','hp'))
),
plotOutput("plot1")
)
))
下面是服务器。R
shinyServer(function(input, output) {
output$plot1 <- renderPlot({
g <- ggplot(data=mtcars, aes(x=mpg, y=input$inputDF, col=factor(cyl)))
g + geom_point() + geom_smooth(method="lm")
})
})
当我单独运行 ggplot 时,情节看起来很完美。
但是,它看起来像一条在Run App 中运行的直线。这有什么问题?我附上了情节。
提前致谢。
【问题讨论】: