mirror of
				https://github.com/bspeice/betterwithdata_cleaning_4
				synced 2025-11-04 02:10:46 -05:00 
			
		
		
		
	Add tab for scatter plot
This commit is contained in:
		@ -1,11 +1,16 @@
 | 
				
			|||||||
library(shiny)
 | 
					library(shiny)
 | 
				
			||||||
 | 
					library(ggplot2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Define server logic required to draw a histogram
 | 
					# Define server logic required to draw a histogram
 | 
				
			||||||
shinyServer(function(input, output) {
 | 
					shinyServer(function(input, output) {
 | 
				
			||||||
  emergency2013 <- read.csv("./data/emergency2013.csv")
 | 
					  emergency2013 <- read.csv("./data/emergency2013.csv")
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  output$distPlot <-renderPlot({
 | 
				
			||||||
 | 
					    plot(emergency2013$duid, emergency2013$vstctgry)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  output$mytable1 <- renderDataTable({
 | 
					  output$mytable1 <- renderDataTable({
 | 
				
			||||||
    library(ggplot2)
 | 
					
 | 
				
			||||||
    emergency2013[, input$show_vars, drop = FALSE]
 | 
					    emergency2013[, input$show_vars, drop = FALSE]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
				
			|||||||
@ -10,14 +10,18 @@ shinyUI(fluidPage(
 | 
				
			|||||||
  sidebarLayout(
 | 
					  sidebarLayout(
 | 
				
			||||||
    sidebarPanel(
 | 
					    sidebarPanel(
 | 
				
			||||||
      checkboxGroupInput('show_vars', 'Columns in dataset to show:',
 | 
					      checkboxGroupInput('show_vars', 'Columns in dataset to show:',
 | 
				
			||||||
                         names(emergency2013), selected = names(emergency2013))
 | 
					                         names(emergency2013), selected = null)
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    # Show a summary table of the selected variables
 | 
					    # Show a summary table of the selected variables
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    mainPanel(
 | 
					    mainPanel(
 | 
				
			||||||
      tabsetPanel(
 | 
					      tabsetPanel(
 | 
				
			||||||
        id = 'dataset',
 | 
					        id = 'dataset',
 | 
				
			||||||
        tabPanel('emergency2013', dataTableOutput('mytable1')))
 | 
					        tabPanel('emergency2013', dataTableOutput('mytable1')),
 | 
				
			||||||
 | 
					        tabPanel('scatterplot', plotOutput('distPlot'))
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
))
 | 
					))
 | 
				
			||||||
		Reference in New Issue
	
	Block a user