head(bwt) age bwt low 1 19 2523 0 2 33 2551 0 3 20 2557 0 4 21 2594 0 5 18 2600 0 6 21 2622 0 str(bwt) ‘data.frame’: 189 obs. of 3 variables: $ age: int 19 33 20 21 18 21 22 17 29 26 … $ bwt: int 2523 2551 2557 2594 2600 2622 2637 2637 2663 2665 … $ low: int 0 0 0 0 0 0 0 0 0 0 … summary(bwt\(bwt) Min. 1st Qu. Median Mean 3rd Qu. Max. 709 2414 2977 2945 3487 4990 table(bwt\)low)
0 1 130 59 > sd(bwt\(bwt)
[1] 729.2143
> hist(bwt\)age, + main = “Histogram of Mother’s Age”, + xlab
= “Age (in years)”, + ylab = “Frequency”, + col = “lightblue”, + border
= “black”) > hist(bwt\(bwt,
+ main = "Histogram of Infant Birth Weight",
+ xlab = "Birth Weight (in grams)",
+ ylab = "Frequency",
+ col = "lightgreen",
+ border = "black")
> boxplot(bwt\)bwt, + main = “Boxplot of Infant Birth Weight”,
+ ylab = “Birth Weight (in grams)”, + col = “orange”, + border =
“brown”) > # Note: The low
variable needs to be a factor
for proper grouping. > bwt\(low <-
as.factor(bwt\)low) > > boxplot(age ~ low, data = bwt, +
main = “Mother’s Age by Low Birth Weight Status”, + xlab = “Low Birth
Weight (0 = No, 1 = Yes)”, + ylab = “Age (in years)”, + col = c(“coral”,
“lightpink”)) > # Note: The low
variable needs to be a
factor for proper grouping. > bwt\(low
<- as.factor(bwt\)low) > > boxplot(age ~ low, data =
bwt, + main = “Mother’s Age by Low Birth Weight Status”, + xlab = “Low
Birth Weight (0 = No, 1 = Yes)”, + ylab = “Age (in years)”, + col =
c(“coral”, “lightpink”)) > knitr::opts_chunk$set(echo = TRUE)