This homework is based on Shiny app.
Q1. Create the following 3 Shiny apps.
- Print a
tableof first n observations from
mpgdata set, where n is the number of observations to print. The default value of n will be 6 while users can select a numeric input anywhere between 1 and 20 observations. (3 points)
Shiny app is visible here: https://malshe.shinyapps.io/problem_1_1/
- Let users select a city from among the five Texan cities and then print “You selected [name of the city]”. Cities: Austin, Dallas, El Paso, Houston, San Antonio (2 points)
Shiny app is visible here: https://malshe.shinyapps.io/problem_1_2/
- Let users select a date and then you print the day of the date. For this use the
lubridatepackage. The default value selected is 2018-09-18. (2 points)
Shiny app is visible here: https://malshe.shinyapps.io/problem_1_3/
Q2. Create a Shiny app to display a histogram of n randomly chosen values from a standard normal distribution. The histogram will be plotted using
ggplot2. The app must have the following 4 controls:
- Number of observations for the histogram. The default number is 100 and the range of number is minimum 50 and maximum 200. Use slider input for this.
- Number of bins for the histogram with 20 as the default. The minimum is 10 and the maximum is 50. Use slider input for this.
fillused in the histogram. Use a dropdown list of the following 5 colors: blue, red, green, yellow, and black
colorused in the histogram. Use a dropdown list of the following 3 colors: red, white, and black
Use a 2-column layout with selectors in the left column (
width = 4) and plot in the right column (
width = 8)
Shiny App is visible here: https://malshe.shinyapps.io/problem_2/
The code to generate random numbers is as follows. Don’t use a random number seed for this exercise. (8 points)
n = # some number randvec = rnorm(n) # randvec is a vector of n random numbers. # Remember that ggplot2 requires a data frame as the input