-
Notifications
You must be signed in to change notification settings - Fork 0
/
histograms.R
44 lines (35 loc) · 845 Bytes
/
histograms.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# histograms
library(ggplot2)
# with ggplot
# > quick plot
qplot(df$col,
geom = histogram,
binwidth = 5,
main = "Title goes here",
xlab = "x axis label",
ylab = " y axis label",
fill = I("blue"),
col = I("red"),
alpha = I(.2),
xlim = c(20, 50),
ylim = c(10, 100),
#.......
)
# > ggplot
ggplot(data = df,
aes(df$col)) +
geom_histogram(breaks=seq(20, 50, by=2),
col='red', fill='green', alpha=.2) +
labs(title="Title goes here", x="x axis label", y="y axis label") +
xlim(c(20, 50)) +
ylim(c(10, 100))
# with hist() fn
said_column <- df$column
hist(said_column,
breaks= 20,
main="Title goes here",
xlab="x axis label",
ylab="y axis label",
col='red',
freq=FALSE
)