Question 1

heights <- c(69, 65, 74)

Question 2

names <- c("Faris", "Jason", "Natty")

Question 3

cbind(heights,names)
##      heights names  
## [1,] "69"    "Faris"
## [2,] "65"    "Jason"
## [3,] "74"    "Natty"

This command assigns each height to specific name in its respective order, the class of it is a matrix.

Question 4

NCbirths <- read.csv("~/Desktop/STATS 13/NCbirths.csv")

Question 5

head(NCbirths)
##   Gender Premie weight Apgar1 Fage Mage Feduc Meduc TotPreg Visits   Marital
## 1   Male     No    124      8   31   25    13    14       1     13   Married
## 2 Female     No    177      8   36   26     9    12       2     11 Unmarried
## 3   Male     No    107      3   30   16    12     8       2     10 Unmarried
## 4 Female     No    144      6   33   37    12    14       2     12 Unmarried
## 5   Male     No    117      9   36   33    10    16       2     19   Married
## 6 Female     No     98      4   31   29    14    16       3     20   Married
##   Racemom Racedad Hispmom Hispdad Gained     Habit MomPriorCond BirthDef
## 1   White   White NotHisp NotHisp     40 NonSmoker         None     None
## 2   White   White Mexican Mexican     20 NonSmoker         None     None
## 3   White Unknown Mexican Unknown     70 NonSmoker At Least One     None
## 4   White   White NotHisp NotHisp     50 NonSmoker         None     None
## 5   White   Black NotHisp NotHisp     40 NonSmoker At Least One     None
## 6   White   White NotHisp NotHisp     21 NonSmoker         None     None
##      DelivComp BirthComp
## 1 At Least One      None
## 2 At Least One      None
## 3 At Least One      None
## 4 At Least One      None
## 5         None      None
## 6         None      None

Question 6

weights <- NCbirths$weight

# Weights are most likely listed in ounces given that grams would be too small.

Question 7

weights.in.pounds <- weights * 0.0625 #ounces to pounds conversion factor

weights.in.pounds[1:20]
##  [1]  7.7500 11.0625  6.6875  9.0000  7.3125  6.1250  9.1875  8.6250  6.5000
## [10]  7.6875  9.5625  8.0625  7.4375  6.7500  6.6250  7.8125  7.1875  8.0000
## [19]  8.2500  5.1875

Question 8

mean_weight_pounds <- mean(weights.in.pounds)
mean_weight_pounds
## [1] 7.2532

Question 9

library(mosaic)
tally(NCbirths$Habit, format = "percent")
## X
## NonSmoker    Smoker 
##  90.61245   9.38755
help(format)

Question 10

library(mosaic)
set.seed(123)
output <- do(200) * rflip(1998,prob=0.2)

Question 11

dotPlot(output$prop)

histogram(output$prop)

Question 12

# Based on my plot and response from question #9, the simulated proportions were higher around 20% 
# and my actual, observed proportion is 9.39% so there is dissonance 
# between the two. This suggests that the observed proportion 
# is actually lower than the 20%.