Below are the solutions to these exercises on Building Shiny App.
Learn more about Shiny in the online course R Shiny Interactive Web Apps – Next Level Data Visualization. In this course you will learn how to create advanced Shiny web apps; embed video, pdfs and images; add focus and zooming tools; and many other functionalities (30 lectures, 3hrs.).
#################### # # # Exercise 1 # # # #################### ##File->New Project->New Directory->Empty Project->Directory Name:Shiny App->Create Project. #################### # # # Exercise 2 # # # #################### ##File -> New File -> RScript -> Save it as:ui.r ##File -> New File -> RScript -> Save it as:server.r #################### # # # Exercise 3 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( )) ##server.R shinyServer(function(input, output) { }) #################### # # # Exercise 4 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel( ), mainPanel() ) )) #################### # # # Exercise 5 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu") ), mainPanel(("Main")) ) )) #################### # # # Exercise 6 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu") ), mainPanel(h1("Main"), p("This famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. ") ) ))) #################### # # # Exercise 7 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu") ), mainPanel(h1("Main"), 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 set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. ") ) ))) #################### # # # Exercise 8 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu") ), mainPanel(h1("Main"), 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 set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. "), br(), h2("Analysis") ) ))) #################### # # # Exercise 9 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu") ), mainPanel(h1("Main"), 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 set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis") ) ))) #################### # # # Exercise 10 # # # #################### ##ui.R library(shiny) shinyUI(fluidPage( titlePanel("Shiny App"), sidebarLayout( sidebarPanel(h2("Menu"), img(src = "petal.jpg", height = 72, width = 100) ), mainPanel(h1("Main"), 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 set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are ",strong( "Iris setosa,"),strong( "versicolor"), "and", strong("virginica.")), br(), h2("Analysis") ) )))
Leave a Reply