forked from splaisan/plotting-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2histo.R
executable file
·43 lines (34 loc) · 1.11 KB
/
2histo.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
#!/usr/bin/Rscript --vanilla
# 2histo.R
# plot a list numbers as histogram from stdin, cat, piped, ...
# add boxplot and quantiles for good measure
#
# Stephane Plaisance (VIB-NC+BITS) 2015/04/02; v1.0
# renamed 2histo.R; v1.01
#
# visit our Git: https://github.com/BITS-VIB
suppressMessages(library("gplots"))
data <- as.numeric(readLines(file("stdin")))
closeAllConnections()
# customize quantiles
p <- c(0, 5, 25, 50, 75, 95, 100)/100
qt <- round( quantile(data,
probs = p,
na.rm = FALSE,
names = TRUE,
type = 7),
3 )
table <- as.data.frame(qt)
colnames(table) <- "Quantiles"
png(file="2histo.png", width = 640, height = 480,
units = "px", pointsize = 12, bg = "white" )
par(mar=c(5, 4, 4, 2)+0.1, mai=c(0.5,0.75,0.5,0.75))
nf <- layout(matrix(c(1,3,2,0), 2, 2,
byrow = TRUE),
widths=c(3,2),
heights=c(3,1),
respect = TRUE)
#layout.show(nf)
hist(data, main="")
boxplot(data, horizontal = TRUE)
textplot(table, halign="left", valign="top", cex=1.5)