412612Test1

docx

School

American University *

*We aren’t endorsed by this school

Course

412

Subject

Statistics

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by SargentRabbit2376

Report
AMERICAN UNIVERSITY STAT 412/612 TEST 1 Be sure to provide all r code that produces the requested plots/output tibbles or data frames . Use ggplot coding to produce graphs and plots as demonstrated in class. Submit all results in a n Rmardown file and a word file or a n Rmarkdown file and a pdf. library(tidyverse) library(dplyr) library(ggplot2) midwest View(midwest) V = ∏r 2 h SA = 2(∏rh + ∏r 2 ) For some of the problems, you have to determine what variables to use. Problems 1 – 10 are for undergraduate (412) and graduate (612) students. # 1 # Using the midwest data frame produce a data table that shows output for the Ohio (OH) only. Produce correct output by using two methods. First use the piping method and then use the assignment method. # 2 # Using the midwest data frame, produce a data table that shows white population that is greater than 50,000 but less than 90,000 for the state of Indiana (IN) # 3 # Using the midwest data , produce a data frame (20 observations) that shows only the variables state, county , poptotal , popamerindian , percamerindian for the state of Indiana. Also, your data frame should show popamerindian in descending order. Which county in Indiana has the highest number of Native Americans? # 4 # Using the midwest data and dplyr functions, create a data frame for only the state of Michigan (MI) showing those counties that have a known poverty population that is greater than 10,000 and a percentage of professionals that is greater than 10 percent. Only select variables that you need for the data frame, your output should only have four variables and six (rows) / observations. # 5 # Using the midwest data and dplyr commands and functions, write r code that will show the mean of the poverty population for the counties of each state. # 6 # Using the midwest data, produce a scatter plot showing a relationship between the variables poppovertyknown and poptotal (Let poptotal = x and poppovertyknown = y). # 7 # Using the midwest data, write r code that will produce the following side by side boxplots.
# 8 # Using the midwest data, write r code that will produce a facet plot that shows scatter plots (red data points) with respect to the levels for the variable state . Also add code that will generate regression lines through your scatter plots that feature x = percollege and y = percprof. Title your facet plot "College/Professional Work Scatter Plots" # 9 # Using the midwest data frame, create a bar graph that shows the different counts for each state in the data set. Your bars should have different colors. Which state has the highest count? # 10 # The formula used to find the volume of a cylinder is V = pi times r squared and the formula to find the Surface Area of a cylinder is A = 2(pi times r times h + pi times r squared) Using the formal notation and process for writing a function, as demonstrated in class, to write a function that will calculate the Volume and the Surface Area of a given cylinder. Test your function by calculating answers for r = 5 and h = 10. # Questions 11 and 12 are for graduate students (612) only # 11 # A partial data frame to be generated from the midwest data frame is given below. Write r code and apply dplyr functions that will produce an additional 20 rows to the 5 rows shown. A tibble: 72 x 6 state county poptotal popadults Ratio Percent <chr> <chr> <int> <int> <dbl> <dbl> 1 Wisconsin ADAMS 15 682 11 378 0.726 72.6
2 Wisconsin ASHLAND 16 307 10 262 0.629 62.9 3 Wisconsin BARRON 40 750 26 198 0.643 64.3 4 Wisconsin BAYFIELD 14 008 9 418 0.672 67.2 5 Wisconsin BROWN 194 594 120 575 0.620 62.0 # 12# Use ggplot coding to produce the side-by-side plots shown below. (Hint: use the categorical variable state and the quantitative variable area of the midwest data table.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help