install.packages("wooldridge")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)

#C2

library(wooldridge)
data("bwght")
#1. how many woman, how many smokers
total_women <- nrow(bwght)
smoking_women <- sum(bwght$cigs > 0)
cat("(i) Total women:", total_women, "\n")
## (i) Total women: 1388
cat("    Women who report smoking during pregnancy:", smoking_women, "\n")
##     Women who report smoking during pregnancy: 212
#2.Average no of cig per day 
average_cigarettes <- mean(bwght$cigs)
cat("\n(ii) Average no of cig per day:", average_cigarettes, "\n")
## 
## (ii) Average no of cig per day: 2.087176
#It is not a good measure because  of the distribution of data and skewness. 
#3. Among women who smoked during pregnancy, what is the average no of cig per day?
smoking_women <- bwght[bwght$cigs > 0, ]
average_cigs_smoked <- sum(smoking_women$cigs) / nrow(smoking_women)

cat("Average no of cig per day among smoking women:", average_cigs_smoked, "\n")
## Average no of cig per day among smoking women: 13.66509
#4. the average of fatheduc
average_fatheduc <- mean(bwght$fatheduc, na.rm = TRUE)

cat("\n(iv) Average of fatheduc:", average_fatheduc, "\n")
## 
## (iv) Average of fatheduc: 13.18624
# Because of the NA, only 1192 observation used to compute this average
#5. Average family income and its standard deviation in dollars.
average_income <- mean(bwght$faminc)
std_dev_income <- sd(bwght$faminc)
cat("\n(v) Average family income in dollars:", average_income, "\n")
## 
## (v) Average family income in dollars: 29.02666
cat("    Standard deviation of family income in dollars:", std_dev_income, "\n")
##     Standard deviation of family income in dollars: 18.73928

#C3