This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.

Let’s load some data to play with:

summary(Boston$crim)
    Min.  1st Qu.   Median     Mean  3rd Qu. 
 0.00632  0.08204  0.25651  3.61352  3.67708 
    Max. 
88.97620 
ggplot(Boston, aes(x=indus, y=medv)) +
    geom_point(shape=19, alpha=1/4) +
    geom_smooth(method=lm)

sort(Boston$nox)[1:100]
  [1] 0.3850 0.3890 0.3920 0.3920 0.3940
  [6] 0.3980 0.3980 0.4000 0.4000 0.4000
 [11] 0.4000 0.4010 0.4010 0.4010 0.4030
 [16] 0.4030 0.4030 0.4040 0.4040 0.4040
 [21] 0.4050 0.4050 0.4050 0.4090 0.4090
 [26] 0.4090 0.4100 0.4100 0.4100 0.4110
 [31] 0.4110 0.4110 0.4110 0.4110 0.4110
 [36] 0.4130 0.4130 0.4130 0.4130 0.4130
 [41] 0.4130 0.4150 0.4150 0.4161 0.4161
 [46] 0.4161 0.4220 0.4260 0.4260 0.4260
 [51] 0.4260 0.4280 0.4280 0.4280 0.4280
 [56] 0.4280 0.4280 0.4280 0.4280 0.4290
 [61] 0.4290 0.4290 0.4310 0.4310 0.4310
 [66] 0.4310 0.4310 0.4310 0.4310 0.4310
 [71] 0.4310 0.4310 0.4330 0.4330 0.4330
 [76] 0.4350 0.4370 0.4370 0.4370 0.4370
 [81] 0.4370 0.4370 0.4370 0.4370 0.4370
 [86] 0.4370 0.4370 0.4370 0.4370 0.4370
 [91] 0.4370 0.4370 0.4370 0.4379 0.4379
 [96] 0.4390 0.4390 0.4390 0.4390 0.4420
stem(Boston$nox)

  The decimal point is 2 digit(s) to the left of the |

  38 | 5922488
  40 | 000011133344455599900011111133333355666
  42 | 26666888888889991111111111333577777777777777777889999
  44 | 222333355555777778888888889999333333888
  46 | 00044444444992222
  48 | 4488888888999999999999999333333339999
  50 | 4444444477777777770000000555555558
  52 | 0000000000044444442222288888888888888888888888
  54 | 4444444444447777777770000
  56 | 3333355
  58 | 0000111111133334444444455555555777777
  60 | 55555555555555999994444444
  62 | 44444444444444411111
  64 | 777777777755599
  66 | 888111111199999999
  68 | 33333333333333
  70 | 00000000000333333333333333333888888
  72 | 
  74 | 0000000000000
  76 | 00000000
  78 | 
  80 | 
  82 | 
  84 | 
  86 | 1111111111111111
ggplot(Boston, aes(x=rm)) +
    geom_histogram(aes(y=..density..),      # Histogram with density instead of count on y-axis
      binwidth=.5, colour="black", fill="white") +
    geom_vline(aes(xintercept=mean(rm, na.rm=T)),   # Ignore NA values for mean
               color="red", linetype="dashed", size=1)+
geom_density(alpha=.2, fill="#FF6666")  # Overlay with transparent density plot

# A basic box with the conditions colored
ggplot(Boston, aes(x=ptratio, y=medv, fill=ptratio>mean(ptratio))) + geom_boxplot()

LS0tCnRpdGxlOiAiUiBOb3RlYm9vayIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKVGhpcyBpcyBhbiBbUiBNYXJrZG93bl0oaHR0cDovL3JtYXJrZG93bi5yc3R1ZGlvLmNvbSkgTm90ZWJvb2suIFdoZW4geW91IGV4ZWN1dGUgY29kZSB3aXRoaW4gdGhlIG5vdGVib29rLCB0aGUgcmVzdWx0cyBhcHBlYXIgYmVuZWF0aCB0aGUgY29kZS4gCgpUcnkgZXhlY3V0aW5nIHRoaXMgY2h1bmsgYnkgY2xpY2tpbmcgdGhlICpSdW4qIGJ1dHRvbiB3aXRoaW4gdGhlIGNodW5rIG9yIGJ5IHBsYWNpbmcgeW91ciBjdXJzb3IgaW5zaWRlIGl0IGFuZCBwcmVzc2luZyAqQ21kK1NoaWZ0K0VudGVyKi4gCgpgYGB7cn0KI2luc3RhbGwucGFja2FnZXMoImdncGxvdDIiKQpsaWJyYXJ5KGdncGxvdDIpCmBgYAoKTGV0J3MgbG9hZCBzb21lIGRhdGEgdG8gcGxheSB3aXRoOgpgYGB7cn0KbGlicmFyeShNQVNTKQpkYXRhKEJvc3RvbikKP0Jvc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