I have a variable "bwt". I am needing to create 4 frequency histograms of the bwt by the race of the individuals. There are 4 races under the name "race": white, black, native american, and other. I know how to make histograms with the hist function, but how would would I separate bwt out for each of the 4 races so I can produce these histograms? I've included the data below.
## patnum hospstay lowph pltct race bwt gest inout twn lol magsulf
## 1 1 34 NA 100 white 1250 35 born at duke 0 NA NA
## 2 2 9 7.250000 244 white 1370 32 born at duke 0 NA NA
## 3 3 -2 7.059998 114 black 620 23 born at duke 0 NA NA
## 4 4 40 7.250000 182 black 1480 32 born at duke 0 NA NA
## 5 5 2 6.969997 54 black 925 28 born at duke 0 NA NA
## 6 6 62 7.189999 NA white 940 28 born at duke 0 NA NA
## meth toc delivery apg1 vent pneumo pda cld sex dead
## 1 0 0 abdominal 8 0 0 0 0 female 0
## 2 1 0 abdominal 7 0 0 0 0 female 0
## 3 0 1 vaginal 1 1 0 0 NA female 1
## 4 1 0 vaginal 8 0 0 0 0 male 0
## 5 0 0 abdominal 5 1 1 0 0 female 1
## 6 1 0 abdominal 8 1 0 0 0 female 0
The code I used to make a simple histogram is included below.
hist(SB_xlsx$bwt, ylab="frequency", xlab="Birth Weight", main="Histogram of Birth Weight")
I do not know how to go about getting the bwt separated by race so I can produce the 4 separate histograms of bwt by race.