RENDER FUNCTIONS
In the 6th percentage of our serial nosotros volition verbalise most the
We are going to create a unproblematic interactive scatterplot that volition attention us run into the clusters that are created when nosotros run the k-means algorithm on our dataset. Read the examples below to empathize how to activate a
renderPlot
and the renderUI
function in addition to and then nosotros volition hold out laid to create our get-go visualization. (Find percentage 1-5 here).We are going to create a unproblematic interactive scatterplot that volition attention us run into the clusters that are created when nosotros run the k-means algorithm on our dataset. Read the examples below to empathize how to activate a
renderPlot
function in addition to the seek yous skills amongst the practice laid nosotros prepared for you. Lets begin! Answers to the exercises are available here.
If you lot obtained a dissimilar (correct) answer than those listed on the solutions page, delight experience gratis to post service your answer every bit a comment on that page.
DESCRIPTIVE STATISTICS
As inwards every statistical application it is wise to apply descriptive statistics on your dataset in addition to also render this information to user inwards an easy-readable way. So, get-go of all nosotros volition house a Data Table within the “SUMMARY”
tabPanel
. The illustration below tin laissez passer on notice hold out your guide. #ui.R
#server.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
),
mainPanel(
dataTableOutput("Table")
)
)))
#server.R
shinyServer(function(input, output, session) {
sum<-as.data.frame.array(summary(iris))
output$Table <- renderDataTable(sum)
})
Exercise 1
Create a Data Table(“Table2”) amongst the descriptive statistics of your dataset. HINT: Use
summary
, as.data.frame.array
and renderDataTable
. renderPlot
The
renderPlot
function enders a reactive plot that is suitable for assigning to an output slot. The full general cast of the percentage that generates the plot is below:renderPlot(expr, width = "auto", acme = "auto", res = 72, ...,
env = parent.frame(), quoted = FALSE, execOnResize = FALSE,
outputArgs = list())
The illustration below shows you lot how to create a unproblematic scatterplot betwixt ii variables of the iris dataset(“Sepal Length” in addition to “Sepal Width”).
# ui.R
#server.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
),
mainPanel(
plotOutput("plot1")
)
)))
#server.R
shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
plot(iris$Sepal.Length,iris$Sepal.Width)
})
})
Initially remove
renderImage
and radioButtons
from the tabPanel
“K means”. Exercise 2
Add a scatterplot within the
tabPanel
“K Means” betwixt ii variables of the iris dataset. INTERACTIVE PLOTS
Shiny has built-in back upwards for interacting amongst static plots generated yesteryear R’s base of operations graphics functions,this makes it slow to add together features similar selecting points in addition to regions, every bit good every bit zooming inwards in addition to out of images.
To acquire the seat of the mouse when a plot is clicked, you lot only postulate to utilisation the click alternative amongst the
To acquire the seat of the mouse when a plot is clicked, you lot only postulate to utilisation the click alternative amongst the
plotOutput
. For example, this app volition impress out the x in addition to y coordinate seat of the mouse cursor when a click occurs. #ui.R
#server.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(),
mainPanel(
plotOutput("plot1", click = "plot_click"),
verbatimTextOutput("info")
)
)))
#server.R
shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
plot(iris$Sepal.Length,iris$Sepal.Width)
})
output$info <- renderText({
paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
})
})
Exercise 3
Add click within the
plotOutput
you exactly created. Name it “mouse”. Exercise 4
Add a
verbatimTextOutput
inside the “K Means” tabPanel
,under the plotOutput
you created before. Name it “coord”. Exercise 5
Make “x” in addition to “y” coordinates look inwards the pre-tag you lot exactly created. HINT : Use
renderText
and paste0
and do non forget to activate it amongst the submitButton
. Exercise 6
Set
height
= “auto” and width
= “auto”. PLOT ANNOTATION
This percentage tin laissez passer on notice hold out used to add together labels to a plot. Its get-go 4 principal arguments tin laissez passer on notice also hold out used every bit arguments inwards most high-level plotting functions. They must hold out of type grapheme or expression. In the latter case, quite a fleck of mathematical annotation is available such every bit sub- in addition to superscripts, greek letters, fraction, etc.
Look at the illustration below:
# ui.R
#server.R
title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
line = NA, outer = FALSE, ...)
Look at the illustration below:
# ui.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(),
mainPanel(
plotOutput("plot1", click = "plot_click"),
verbatimTextOutput("info")
)
)))
#server.R
shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
plot(iris$Sepal.Length,iris$Sepal.Width,main = "SCATTER PLOT",sub = "K Means",xlab="Sepal Length",ylab = "Sepal Width")
})
output$info <- renderText({
paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
})
})
Exercise 7
Set scatterplot championship to “K-Means”, the X-axis label to “Petal Length” in addition to the Y-axis label to “Petal Width”. HINT: Use
main
,xlab
,ylab
. You tin laissez passer on notice also alter in addition to laid other graphical parameters related to the championship in addition to subtitle similar the illustration below:
# ui.R
#server.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(),
mainPanel(
plotOutput("plot1", click = "plot_click"),
verbatimTextOutput("info")
)
)))
#server.R
shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
plot(iris$Sepal.Length,iris$Sepal.Width,main = "SCATTER PLOT",sub = "K Means",xlab="Sepal Length",ylab = "Sepal Width",
cex.main = 3, font.main= 5, col.main= "green",
cex.sub = 0.65, font.sub = 4, col.sub = "orange")
})
output$info <- renderText({
paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
})
})
Exercise 8
Give values to the residual of the graphical parameters of the championship similar the illustration to a higher house in addition to acquire used to them. HINT: Use
cex.main
, font.main
and col.main
. renderUI
renderUI(expr, env = parent.frame(), quoted = FALSE, outputArgs = list())
Makes a reactive version of a percentage that generates/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", radioButtons("radio", label = h4("Select Image"), choices = list("Choice 1" = 1, "Choice 2" = 2), selected = 1), imageOutput("Image"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$Image <- renderImage({ filename <- normalizePath(file.path('./images', paste('pic', input$radio, '.png', sep=''))) list(src = filename, width=300, height=200) },deleteFile = FALSE) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris)}) #################### # # # Exercise 2 # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width) }) }) #################### # # # Exercise three # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width) }) }) #################### # # # Exercise 4 # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width) }) }) #################### # # # Exercise five # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width) }) output$coord <- renderText({ paste0("x=", input$mouse$x, "\ny=", input$mouse$y) }) }) #################### # # # Exercise 6 # # # #################### library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width) }, width = "auto",height = "auto") output$coord <- renderText({ paste0("x=", input$mouse$x, "\ny=", input$mouse$y) }) }) #################### # # # Exercise seven # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width,main = "K-MEANS",xlab="Petal Length",ylab = "Petal Width") }, width = "auto",height = "auto") output$coord <- renderText({ paste0("x=", input$mouse$x, "\ny=", input$mouse$y) }) }) #################### # # # Exercise 8 # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #################### # # # Exercise ix # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), uiOutput("All"), sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1"), submitButton("Submit"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width,main = "K-MEANS",xlab="Petal Length",ylab = "Petal Width", cex.main = 2, font.main= 4, col.main= "blue") }, width = "auto",height = "auto") output$coord <- renderText({ paste0("x=", input$mouse$x, "\ny=", input$mouse$y) }) output$All <- renderUI({ tagList( ) }) }) #################### # # # Exercise 10 # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), br(), fluidRow( column(6, h4("Actionbutton"), actionButton("per", label = "Perform")), column(6, h4("Help Text"), helpText("Just for help"))), br(), fluidRow( column(6, numericInput("numer", label = h4("Numeric Input"), value = 10))), fluidRow( column(6, h4("Single Checkbox"), checkboxInput("checkbox", label = "Choice A", value = TRUE))), fluidRow( column(6, checkboxGroupInput("checkGroup", label = h4("Checkbox group"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 2)), column(6, selectInput("select", label = h4("Select Box"), choices = list("Choice 1" = 1, "Choice 2" = 2 ), selected = 1))), fluidRow( column(6, dateInput("date", label = h4("Date input"), value = "2016-12-01")), column(6 )), fluidRow( column(6, dateRangeInput("dates", label = h4("Date Range"))), column(6, textInput("text", label = h4("Text Input"), value = "Some Text"))), fileInput("file", label = h4("File Input"))), mainPanel(h1("Main"), img(src = "petal.jpg", height = 150, width = 200), br(), br(), p("This famous (Fisher's or Anderson's) ", a("iris",href="http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/iris.html"), "data laid gives the measurements inwards centimeters of the variables sepal length in addition to width in addition to petal length in addition to width, respectively, for fifty flowers from each of three species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis"), tabsetPanel(type="tabs",tabPanel("Data Table",dataTableOutput("Table")), tabPanel("Summary",dataTableOutput("Table2")), tabPanel("K means", plotOutput("plot1",click = "mouse"), verbatimTextOutput("coord"), uiOutput("All"))) ) ) )) #server.R shinyServer(function(input, output) { output$Table <- renderDataTable( iris,options = list( lengthMenu = list(c(10, 20, 30,-1),c('10','20','30','ALL')), pageLength = 10)) output$text1 <- renderText({ paste("You accept selected", input$slider1,"clusters") }) sumiris<-as.data.frame.array(summary(iris)) output$Table2 <- renderDataTable(sumiris) output$plot1 <- renderPlot({ plot(iris$Petal.Length,iris$Petal.Width,main = "K-MEANS",xlab="Petal Length",ylab = "Petal Width", cex.main = 2, font.main= 4, col.main= "blue") }, width = "auto",height = "auto") output$coord <- renderText({ paste0("x=", input$mouse$x, "\ny=", input$mouse$y) }) output$All <- renderUI({ tagList( sliderInput("slider1", label = h4("Clusters"), min = 3, max = 10, value = 3), textOutput("text1") ) }) })