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()