...
[iramuteq] / Rlib / textometrieR / R / pareto.R
1 #*
2 #* Textometrie 
3 #* ANR project ANR-06-CORP-029
4 #* http://textometrie.ens-lsh.fr/
5 #* 
6 #* 2008 (C) Textometrie project
7 #* BSD New and Simplified BSD licenses
8 #* http://www.opensource.org/licenses/bsd-license.php
9
10 `pareto` <-
11 function (x) {
12   op <- par(mar = c(5, 4, 4, 5) + 0.1)
13   par(las=2)
14   if( ! inherits(x, "table") ) {
15     x <- table(x)
16   }
17   x <- rev(sort(x))
18   plot( x, type='h', axes=F)
19   # , lwd=16
20   axis(2)
21   points( x, type='h', lwd=6) # , col=heat.colors(length(x)) 
22   
23   y <- cumsum(x)/sum(x)
24   par(new=T)
25   plot(y, type="b", lwd=3, pch=7, axes=F, xlab='', ylab='', main='')
26   points(y, type='h')
27   axis(4)
28   #print(names(x))
29   axis(1, at=1:length(x), labels=names(x))
30   par(op)
31   title("Pareto graphic with cumulative frequency");
32 }
33