Question
This homework is designed to give you practice with calculating error bars (confidence intervals) with ddply and using ggplot2 graphics to produce insightful plots of
This homework is designed to give you practice with calculating error bars (confidence intervals) with ddply and using ggplot2 graphics to produce insightful plots of the results.
library(plyr) library(dplyr) library(ggplot2)
You will continue using theadultdata set that you first encountered on Homework 3. This data set is loaded below.
adult.data <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data", header=FALSE, fill=FALSE, strip.white=T, col.names=c("age", "type_employer", "fnlwgt", "education", "education_num","marital", "occupation", "relationship", "race","sex", "capital_gain", "capital_loss", "hr_per_week","country", "income")) adult.data <- mutate(adult.data, high.income = as.numeric(income == ">50K"))
Problem 1: Calculating and plotting error bars for a 1-sample t-test
(a) Usingddplyand 1-sample t-testing, construct a table that shows the averagecapital_gainacrosseducation, along with the lower and upper endpoints of a 95% confidence interval. Your table should look something like:
education mean lower upper 1 10th 404.5745 91.893307 717.2557 2 11th 215.0979 144.306937 285.8888 3 12th 284.0878 126.824531 441.3510 ... # Edit me
(b) Reorder the levels of the factor in your summary table to correspond to ascending order of education. E.g., Preschool is the lowest, 1st-4th the next lowest, etc. You may find thefactor(..., levels = ...)command helpful here. For the post-high school grades, you can use the ordering: Assoc-voc, Assoc-acdm, Some-college, Bachelors, Masters, Prof-school, Doctorate.
# Edit me
Need help with this assignment r studio Jupiter notebooks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started