Adding if statements for checkboxGroupInput in Shiny
<p>I'm having issues adding a checkboxes in a shiny app. I want to be able to check  to add either a linear regression line, loess, or none at all. This is using the diamond data. 
Any help would be greatly appreciated:</p>

<p><strong>ui.R</strong></p>

<pre><code>library(shiny)
shinyUI(fluidPage(
fluidRow(
sidebarLayout(
  sidebarPanel(
    numericInput("size","Size",value=1,min=0,max=1,step=0.1),
    sliderInput("opaqueness","Opaqueness",0,min=0,max=1),
    checkboxInput("color","Color",value=T),
    checkboxGroupInput("lines","Lines",choices=c("lm","loess"))
    #add inputs

    ),
  mainPanel(
    plotOutput("diamondgraph")
  )
)
)
))
</code></pre>

<p><strong>server.R</strong></p>

<pre><code>library(dplyr)
library(ggplot2)
library(shiny)
data&lt;-diamonds
data&lt;-filter(data,color=="E"|color=="I"|color=="J")


shinyServer(function(input, output) {
  output$diamondgraph&lt;-renderPlot({
g&lt;-ggplot(data=data,aes(x=carat,y=price))
if (input$color){
  gcol&lt;-g+geom_point(aes(color=color),alpha=input$opaqueness,size=input$size)+scale_x_log10()+
    ggtitle("Scatterplot of Carat vs Price")

}else{
  gcol&lt;-g+geom_point(alpha=input$opaqueness, size=input$size)+
    geom_smooth()+
    scale_x_log10()+
    ggtitle("Scatterplot of Carat vs Price")
}
if (input$lines =="lm"){
  gcol&lt;-g+geom_point(aes(color=color),alpha=input$opaqueness,size=input$size)+geom_smooth(aes(color=color, method=lm))+scale_x_log10()+
    ggtitle("Scatterplot of Carat vs Price")
}
if 
(input$lines == "loess"){
  gcol&lt;-g+geom_point(aes(color=color),alpha=input$opaqueness,size=input$size)+geom_smooth(aes(color=color)) + scale_x_log10()+
    ggtitle("Scatterplot of Carat vs Price")
} else 
  gcol&lt;-g+geom_point(aes(color=color),alpha=input$opaqueness,size=input$size) + scale_x_log10()+
    ggtitle("Scatterplot of Carat vs Price")
gcol
   })

})
</code></pre>