With the babies data set in openintro, use a summary table to investigate whether first pregnancy status correlates with gestation length or not. Use pipe operator for your code. Submit yoru code and the result.

Answer:

fp<- babies %>%
  mutate(parity_label = fct_recode(as.factor(parity), "first_pregnancy" = "0", "not_first_pregnancy" = "1")) %>%
    group_by(parity_label)%>%
    summarise(n = n(), mean_gest = mean(gestation, na.rm = TRUE), median_gest = median(gestation, na.rm = TRUE)) %>%
    print()
## # A tibble: 2 × 4
##   parity_label            n mean_gest median_gest
##   <fct>               <int>     <dbl>       <dbl>
## 1 first_pregnancy       921      279.         279
## 2 not_first_pregnancy   315      281.         282

Based on the table, there is little difference in the measures and it seems that first pregnancy or not does not matter to the gestation length.