Learn R Programming

scatterPlotMatrix (version 0.3.0)

setRegressionType: Regression plots

Description

Tells which type of regression to use for regression plots.

Usage

setRegressionType(id, regressionType)

Value

No return value, called from shiny applications for side effects.

Arguments

id

Output variable to read from (id which references the requested plot).

regressionType

Binary code indicating the type of regression plot (bit 1: linear, bit 2: loess).

Examples

Run this code
 if(interactive() && require(shiny)) {
   library(shiny)
   library(scatterPlotMatrix)

   ui <- fluidPage(
     checkboxInput("linearRegressionCB", "Linear Regression", FALSE),
     checkboxInput("loessCB", "Local Polynomial Regression", FALSE),
     p("The chech boxes controls type of regression to use for regression plots"),
     scatterPlotMatrixOutput("spMatrix")
   )

   server <- function(input, output, session) {
     output$spMatrix <- renderScatterPlotMatrix({
       scatterPlotMatrix(iris)
     })
     observe({
       linearFlag <- ifelse(input$linearRegressionCB, 1, 0)
       loessFlag <- ifelse(input$loessCB, 2, 0)
       scatterPlotMatrix::setRegressionType("spMatrix", linearFlag + loessFlag)
     })
   }

   shinyApp(ui, server)
 }

Run the code above in your browser using DataLab