程序代写代做代考 html 10/27/2020 STAT 413/613 Homework: Shiny

10/27/2020 STAT 413/613 Homework: Shiny
STAT 413/613 Homework: Shiny
Your Name 2020-10-12
Instructions
HINT: Use the following to guide your app development Learning Outcome
Rubric
1 Create a Shiny app based on the mpg dataset from the ggplot2 package. 2 Create a Shiny app based on the mtcars data set.
3 Housing Sales App
3.1 Build a Shiny App with the following attributes:
3.2 Extra Credit Tab 2 4 Extra Credit Webinar
Instructions
Create three Apps in the appropriate folders in the homework repo in accordance with the instructions below.
Delete the Untitled.R files in the R directories
For each App, put your name in a comment at the top of the app.R file.
Include any citations or references in the comments as well.
Place all of your solution Shiny code in the appropriate app folders.
Make sure to commit often, consider branches, and push each time you answer a question or you want me to look at code.
Submit a note on Canvas when your apps are complete and ready for scoring.
If you want to answer the extra credit question at the end, please add your answers to your submission note on Canvas
HINT: Use the following to guide your app development
file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 1/6

10/27/2020 STAT 413/613 Homework: Shiny
Courtesy of https://engineering-shiny.org/ (https://engineering-shiny.org/)
Learning Outcome
Create Shiny Apps with increasing levels of sophistication.
Rubric
Part
1.mpg App 1.mpg App 1.mpg App 2.mtcars App 2.mtcars App 2.mtcars App 3.HOusing App 3a.Tab 1 3a.Tab 1 3a.Tab1 3a.Tab1
Pts Element
1. Working App
1. Correct Input capabilities
1. Correct Plot Outputs
1. Working App
2. Correct Input capabilities
2. Correct Plot Outputs
1. Data is loaded and Transformed before the UI code
2. Numeric Input and Output
2. Factor Input and Output
2. Log Input and Output and error message using validate() 3. t.test Input and Output
file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 2/6

10/27/2020 STAT 413/613 Homework: Shiny
Part
3b.Tab2
3b.Tab2
3b.Tab2
3b.Tab2
3b.Tab2
3b.Tab 2 Extra Credit 3b.Tab 2 Extra Credit 3b.Tab 2 Extra Credit 3c.Tab3
4.Extra Credit Webinar
Pts
4. 4. 4. 4. 4. 1. .5 .5 2. 1.
Element
Numeric and Numeric
Numeric and Factor
Factor and Factor
Log Input and Output and error message using validate() OLS Input and Output
EC: LM Summary
EC: Residual Plot
EC: QQ Plot
Data Table
Answers to Questions Plus 3 Extra Credit
Total 40
1 Create a Shiny app based on the mpg
dataset from the ggplot2 package.
Allow a user to select three variables from the dataset.
The app should output a scatterplot of two of the variables and color code the points by the third variable.
Make the default variables the ones in the image below. Your app should look similar to this:
file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 3/6

10/27/2020 STAT 413/613 Homework: Shiny
2 Create a Shiny app based on the mtcars data set.
Take as input a variable from the mtcars dataset to plot as well as the type of plot (histogram, density, or frequency polygon).
Hint: Recall plots are objects you can build one layer at a time. Taking advantage of this modular nature of ggplot2 will make your code simpler:
Your app should look similar to this:
file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 4/6

10/27/2020 STAT 413/613 Homework: Shiny
3 Housing Sales App
Researchers were interested in predicting residential home sales prices in a Midwestern city as a function of various characteristics of the home and surrounding property. Data on 522 transactions were obtained for home sales during the year 2002. The 13 variables are:
Price: Sales price of residence (in dollars)
Area: Finished area of residence (in square feet)
Bed: Total number of bedrooms in residence
Bath: Total number of bathrooms in residence
AC: 1 = presence of air conditioning, 0 = absence of air conditioning Garage: Number of cars that a garage will hold
Pool: 1 = presence of a pool, 0 = absence of a pool
Year: Year property was originally constructed
Quality: Index for quality of construction. High, Medium, or Low. Style: Categorical variable indicating architectural style
Lot: Lot size (in square feet)
Highway: 1 = highway adjacent, 0 = highway not adjacent.
We¡¯ve seen these data a few times before.
3.1 Build a Shiny App with the following attributes:
1. Three tabs. The first tab is for univariate analysis. The second tab is for bivariate analysis. The third tab is for a spreadsheet of the numeric variables in the data.
Transform the data so AC , Pool and Highway are factors and Price is in thousands of dollars.
file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 5/6

10/27/2020 STAT 413/613 Homework: Shiny
2. The inputs/outputs for the univariate analysis should be:
The variable of interest.
Do the analysis on log-transformed data or not?
The number of bins in the histogram.
The null value for a one-sample t-test.
Output the results of the one-sample t-test. The results of the test should be in accordance with the user¡¯s choice of a log transformation (or not) for the data .
Output a histogram if the variable is numeric and a barplot otherwise.
Use validate() to output an error message if the log transform is checked for a factor
3. The inputs/outputs for the bivariate analysis should be:
The variable of interest for the X axis and the Y axis.
Whether to log each variable.
Whether to add an OLS line.
Output a scatter plot if both variables are numeric, a boxplot if one is numeric and one is categorical, and a jitter plot if both are categorical.
Use validate() to output an error message if the log transform is checked for a factor
4. The spreadsheet tab should contain a Data Table with only the numeric variables. Use a map*() function
to select these.
5. Try to make your Shiny app as visually similar to my app as you can.
Hint: You can make this a lot easier by taking advantage of the modularity built into ggplot2:
pl <- ggplot(mtcars, aes(x = disp, y = mpg)) if (...){ pl <- pl + geom_point() } else if(...){ pl <- pl + scale_x_log10() } pl Hint: I found it easier to use geom_boxploth() from the ggstance library instead of using coord_flip(). 3.2 Extra Credit Tab 2 Only if the OLS line is requested, add another row of output: On the left, a summary from running a linear model on the chosen inputs and outputs to include any log transforms In the middle, a plot of the residuals versus fitted On the right, a QQ plot of the residuals 4 Extra Credit Webinar Listen to Epsiode 1 (https://shinydevseries.com/post/episode-1-shiny-development-past-and-future/) of the RStudio Shiny Developer Series" webinars and provide one sentence answers to the following questions: 1. How has the R Studio shiny development changed their focus over the past several years? 2. How does your approach to writing shiny apps change when you think they will need to be maintained over the long run by your ¡°future self¡± or others? file:///Users/sdd/Desktop/AU/map2/R/STAT-613/homework/hw-06-DoudouShi/analysis/hw03_shiny.html 6/6