## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 189 obs. of 6 variables:
## $ low : chr "less_than_2.5_kg" "less_than_2.5_kg" "less_than_2.5_kg" "less_than_2.5_kg" ...
## $ age : num 20 21 18 22 29 26 18 18 25 28 ...
## $ race : chr "one" "one" "one" "one" ...
## $ smoke_during_preg_1_yes : num 1 1 1 0 1 1 1 1 1 1 ...
## $ ht_history_hypetension_1_yes: num 0 0 0 0 0 0 0 0 0 0 ...
## $ bwt_kg : num 2557 2594 2600 2637 2663 ...
## - attr(*, "spec")=
## .. cols(
## .. low = col_character(),
## .. age = col_double(),
## .. race = col_character(),
## .. smoke_during_preg_1_yes = col_double(),
## .. ht_history_hypetension_1_yes = col_double(),
## .. bwt_kg = col_double()
## .. )
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 2000 obs. of 8 variables:
## $ AGE : num 30 56 55 47 50 45 25 61 50 19 ...
## $ GENDER : num 0 0 0 1 1 1 0 1 0 1 ...
## $ EXPENDIP: num 0 0 16121 0 0 ...
## $ EXPENDOP: num 0 2385 29730 110 3299 ...
## $ RACE : chr "WHITE" "BLACK" "WHITE" "BLACK" ...
## $ REGION : chr "MIDWEST" "SOUTH" "MIDWEST" "NORTHEAST" ...
## $ EDUC : chr "LHIGHSC" "HIGHSCH" "COLLEGE" "COLLEGE" ...
## $ MARISTAT: chr "MARRIED" "MARRIED" "MARRIED" "MARRIED" ...
## - attr(*, "spec")=
## .. cols(
## .. AGE = col_double(),
## .. GENDER = col_double(),
## .. EXPENDIP = col_double(),
## .. EXPENDOP = col_double(),
## .. RACE = col_character(),
## .. REGION = col_character(),
## .. EDUC = col_character(),
## .. MARISTAT = col_character()
## .. )
plot(as.factor(birthwt$low),
xlab = "Birth Weight",
ylab = "Frequency",
ylim = c(0,150),
col = "purple", main = "Distribution of Birth Weight")plot(as.factor(expd$REGION),
xlab = "Region",
ylab = "Frequency",
ylim = c(0,800),
col = "green",
main = "Regional Distribution")plot(as.factor(birthwt$low), as.factor(birthwt$race),
xlab = "Birth Weight",
ylab = "Race (Proportion)",
ylim = c(0,150),
main = "Distribution of Race by Birth Weight")## Warning in spineplot.default(x, y, ...): y axis is on a cumulative probability
## scale, 'ylim' must be in [0,1]
plot(as.factor(expd$EDUC), as.factor(expd$REGION),
xlab = "Region",
ylab = "Frequency",
ylim = c(0,800),
main = "Regional Distribution by Education")## Warning in spineplot.default(x, y, ...): y axis is on a cumulative probability
## scale, 'ylim' must be in [0,1]
library(RColorBrewer)
tbl <- as.data.frame(table(birthwt$race))
pie(tbl[,2],
labels = row.names(tbl),
col = brewer.pal(3, "Spectral"),
main="Pie Chart of Birth Weight")
legend("topright",
legend = row.names(tbl),
fill = brewer.pal(3, "Spectral"))tbl1 <- table(expd$MARISTAT)
labl <- paste(names(tbl1), "\n", tbl1, sep="")
pie(tbl1, labels = labl,
main="Pie Chart of Marital Status")hist(birthwt$bwt_kg,
xlab = "Actual Birth Weight (kg)",
ylim = c(0,50),
main = "Histogram of Actual Birth Weights")hist(birthwt$bwt_kg,
breaks = 6,
xlab = "Actual Birth Weight (kg)",
ylim = c(0,100),
main = "Histogram of Actual Birth Weights")hist(expd$EXPENDIP,
xlab = "Inpatient Medical Expenditure",
ylim = c(0,2500),
main = "Histogram of Inpatient Medical Expenditure")boxplot(expd$AGE,
xlab = "Inpatient Medical Expenditure",
horizontal = TRUE,
main = "Boxplot of Inpatient Medical Expenditure")boxplot(expd$AGE~expd$REGION,
xlab = "Region",
ylab = "Inpatient Medical Expenditure",
horizontal = FALSE,
col = "blue",
main = "Histogram of Inpatient Medical Expenditure")