Introduction

Question2

Variation

Typical Values

diamonds %>%
  filter(carat < 3) %>%
  ggplot(aes(x = carat)) +
  geom_histogram(binwidth = .01)

faithful %>%
  ggplot(aes(eruptions))

Visualize Distributions

diamonds %>%
  ggplot(aes(x=cut))

geom_bar()
## geom_bar: just = 0.5, width = NULL, na.rm = FALSE, orientation = NA
## stat_count: width = NULL, na.rm = FALSE, orientation = NA
## position_stack
diamonds %>%
  ggplot(mapping = aes(x = carat))

geom_histogram(binwidth = 0.5)
## geom_bar: na.rm = FALSE, orientation = NA
## stat_bin: binwidth = 0.5, bins = NULL, na.rm = FALSE, orientation = NA, pad = FALSE
## position_stack

###Unusual Values

diamonds %>%
  ggplot(aes(y)) +
  geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

diamonds %>%
  ggplot(aes(y)) +
  geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

coord_cartesian(ylim = c(0,50))
## <ggproto object: Class CoordCartesian, Coord, gg>
##     aspect: function
##     backtransform_range: function
##     clip: on
##     default: FALSE
##     distance: function
##     expand: TRUE
##     is_free: function
##     is_linear: function
##     labels: function
##     limits: list
##     modify_scales: function
##     range: function
##     render_axis_h: function
##     render_axis_v: function
##     render_bg: function
##     render_fg: function
##     setup_data: function
##     setup_layout: function
##     setup_panel_guides: function
##     setup_panel_params: function
##     setup_params: function
##     train_panel_guides: function
##     transform: function
##     super:  <ggproto object: Class CoordCartesian, Coord, gg>

Missing Values

diamonds %>%
  
  filter(y < 3 | y > 20)
## # A tibble: 9 × 10
##   carat cut       color clarity depth table price     x     y     z
##   <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
## 1  1    Very Good H     VS2      63.3    53  5139  0      0    0   
## 2  1.14 Fair      G     VS1      57.5    67  6381  0      0    0   
## 3  2    Premium   H     SI2      58.9    57 12210  8.09  58.9  8.06
## 4  1.56 Ideal     G     VS2      62.2    54 12800  0      0    0   
## 5  1.2  Premium   D     VVS1     62.1    59 15686  0      0    0   
## 6  2.25 Premium   H     SI2      62.8    59 18034  0      0    0   
## 7  0.51 Ideal     E     VS1      61.8    55  2075  5.15  31.8  5.12
## 8  0.71 Good      F     SI2      64.1    60  2130  0      0    0   
## 9  0.71 Good      F     SI2      64.1    60  2130  0      0    0

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.