Changes as axis range increases
addhealth %>% ggvis(~age) %>% layer_histograms(width = 1) %>%
scale_numeric("y", domain = c(0, 1800), nice = FALSE) %>%
add_axis("y", title = "Count", title_offset="50") %>%
add_axis("x", title = "Age", title_offset="50")
summary(age)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 10.00 14.00 15.00 14.96 16.00 19.00 7
range(age, na.rm=TRUE)
## [1] 10 19
IQR(age, na.rm=TRUE)
## [1] 2
#MODE(age)
addhealth %>% ggvis(~grade) %>% layer_histograms(width = 1) %>%
scale_numeric("y", domain = c(0, 1800), nice = FALSE) %>%
add_axis("y", title = "Count", title_offset="50") %>%
add_axis("x", title = "Grade", title_offset="50")
summary(grade)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 7.000 8.000 10.000 9.638 11.000 13.000
range(grade, na.rm=TRUE)
## [1] 7 13
IQR(grade, na.rm=TRUE)
## [1] 3
#MODE(grade)
addhealth %>% ggvis(~tvhrs) %>% layer_histograms(width = 1) %>%
scale_numeric("y", domain = c(0, 1800), nice = FALSE) %>%
add_axis("y", title = "Count", title_offset="50") %>%
add_axis("x", title = "Hours of TV", title_offset="50")
summary(tvhrs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 5.00 10.00 16.03 21.00 99.00
range(tvhrs, na.rm=TRUE)
## [1] 0 99
IQR(tvhrs, na.rm=TRUE)
## [1] 16
#MODE(tvhrs)
## Histogram of Hours Playing Computer Games Per Week
addhealth %>% ggvis(~compgamehrs) %>% layer_histograms(width = 1) %>%
scale_numeric("y", domain = c(0, 1800), nice = FALSE) %>%
add_axis("y", title = "Count", title_offset="50") %>%
add_axis("x", title = "Hours of Computer Games", title_offset="50")
summary(compgamehrs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 0.000 1.000 2.751 3.000 99.000
range(compgamehrs, na.rm=TRUE)
## [1] 0 99
IQR(compgamehrs, na.rm=TRUE)
## [1] 3
#MODE(compgamehrs)