In this exercise we weill use the Add Health data to try some graphing. first we will load the add health data.
This first part loads the programs we need.
First let’s make a histogram of age. This show the number at each age. The age variable is S3
addhealth %>% ggvis(~S3) %>% layer_histograms()
## Guessing width = 0.2 # range / 35
Put these next %>% add_axis(“x”, title = “Age”) %>% add_axis(“y”, title = “Count”)
addhealth %>% ggvis(~S3) %>% layer_histograms() %>% add_axis("x", title = "Age") %>%
add_axis("y", title = "Count")
## Guessing width = 0.2 # range / 35
addhealth %>% ggvis(~S3) %>% layer_histograms() %>%
add_axis("x", title = "Age", title_offset="50") %>%
add_axis("y", title = "Count", title_offset="50")
## Guessing width = 0.2 # range / 35
addhealth %>% ggvis(~S3) %>% layer_histograms()
## Guessing width = 0.2 # range / 35
stroke := (This is the outline. Put the name of a color or number of a color in quotation marks) fill := (This is what goes in the middle)
addhealth %>% ggvis(~S3) %>% layer_histograms(fill := "pink", stroke="blue")
## Guessing width = 0.2 # range / 35
width (changes how wide the bars are, based on the values of your variable) center (usually 0 or .5)
addhealth %>% ggvis(~S3) %>% layer_histograms(width=5, center = 0)
addhealth %>% ggvis(~S3) %>% layer_histograms(width=1, center = .5)
You can combine these together.
(You can break up the lines, makes sure to put the %>% at the end of each line.)
addhealth %>%
ggvis(~S3) %>%
layer_histograms(fill := "pink", stroke="blue", width=1, center = .5) %>%
add_axis("x", title = "Age") %>%
add_axis("y", title = "Count")
Below make 5 different versions of the histogram for age.
Type your answer below:
Type answer below:
The variable name for grade is S3. Make a histogram for grade.
Type answer below: