Вы находитесь на странице: 1из 4

Megh Mehta

Assignment 2

source("http://www.openintro.org/stat/data/cdc.R")

View(cdc)

# Q1.
plot(cdc$weight ~ cdc$wtdesire)
#Q2.
cdc$wdiff<- (cdc$wtdesire-cdc$weight)
wdiff <- cdc$wtdesire-cdc$weight
class(wdiff)
[1] "integer"
#wdiff is integer and discrete
#If an observation is 0, then the respondent is satisfied with their current weight
#If wdiff is negative, than they want to lose weight, if it is positive, they want to gain weight

#Q3
hist(wdiff, breaks = 30)

boxplot(wdiff)
summary(wdiff)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-300.00 -21.00 -10.00 -14.59 0.00 500.00

#Wdiff median = -10, mean = -14.59, so it’s typical for people to want to lose around 10 to 15
pounds

#The Wdiff histogram is unimodal with a slight left skew, so there are some people who want
to lose a lot of weight, and few people who want to gain weight

#The iqr spread is between 0 and -21 pounds, although there are many outliers, mostly of
people who want to lose weight

#Q4

genderwdiff <- data.frame(wdiff, cdc$gender)


summary(subset(genderwdiff, cdc.gender == "m"))
summary(subset(genderwdiff, cdc.gender == "f"))
boxplot(genderwdiff$wdiff ~ genwdiff$cdc.gender)

#Women (median = -10) generally appear to want to lose a few more pounds than men
(median = -5), and women have a slightly larger range of how much they want to lose/gain
(iqr = 27) than men (iqr = 20). Interestingly, more men than women appear to want to gain
weight.

#Q5
mean <- mean(cdc$weight)
sd <- sd(cdc$weight)

proportion <- subset(cdc, weight < (mean + sd) & weight > (mean - sd))
dim(proportion)/dim(cdc)

#mean of weight = 169.7


#standard deviation = 40.08
#proportion within one standard deviation of the mean = .7076

Вам также может понравиться