I am trying to calculate descriptive statistics for the birthweight data set (birthwt
) found in RStudio. However, I'm only interested in a few variables: age
, ftv
, ptl
and lwt
.
This is the code I have so far:
library(MASS)
library(dplyr)
data("birthwt")
grouped <- group_by(birthwt, age, ftv, ptl, lwt)
summarise(grouped,
mean = mean(bwt),
median = median(bwt),
SD = sd(bwt))
It gives me a pretty-printed table but only a limited number of the SD is filled and the rest say NA
. I just can't work out why or how to fix it!