R 在浏览器中,光泽中的打印显示不同

R 在浏览器中,光泽中的打印显示不同,r,shiny,R,Shiny,我试着用Shining编写一个简单的应用程序。下面是ui.R library(shiny) library(ggplot2) shinyUI(fluidPage( titlePanel("Explore mtcars dataset"), sidebarLayout( sidebarPanel( selectInput("inputDF","Enter Y to plot vs mpg",choices =

我试着用Shining编写一个简单的应用程序。下面是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")
  )
))
下面是服务器

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")
  })
})
shinyServer(功能(输入、输出){

输出$plot1最简单的方法是使用
aes\u string
而不是
aes
来处理
input$inputDF
中的字符串输入:

g <- ggplot(data=mtcars, aes_string(x='mpg', y=input$inputDF, col='factor(cyl)'))
g
library(rlang)
g <- ggplot(data=mtcars, aes(x=mpg, y= !! sym(input$inputDF), col=factor(cyl)))