1Fsdb::Filter::dbcolpercUesnetrilCeo(n3t)ributed Perl DocFusmdebn:t:aFtiilotner::dbcolpercentile(3)
2
3
4
6 dbcolpercentile - compute percentiles or ranks for an existing column
7
9 dbcolpercentile [-rplhS] column
10
12 Compute a percentile of a column of numbers. The new column will be
13 called percentile or rank. Non-numeric records are handled as in other
14 programs.
15
16 If the data is pre-sorted and only a rank is requested, no extra
17 storage is required. In all other cases, a full copy of data is
18 buffered on disk.
19
21 -p or --percentile or --mode percentile
22 Show percentile (default). Percentile is the percentage of the
23 cumulative values at or lower than the current value, relative to
24 the total count.
25
26 -P or --rank or --nopercentile or --mode rank
27 Compute ranks instead of percentiles.
28
29 --fraction
30 Show fraction (percentage, except between 0 and 1, not cumulative
31 fraction).
32
33 -a or --include-non-numeric
34 Compute stats over all records (treat non-numeric records as zero
35 rather than just ignoring them).
36
37 -S or --pre-sorted
38 Assume data is already sorted. With one -S, we check and confirm
39 this precondition. When repeated, we skip the check.
40
41 -f FORMAT or --format FORMAT
42 Specify a printf(3)-style format for output statistics. Defaults
43 to "%.5g".
44
45 -T TmpDir
46 where to put tmp files. Also uses environment variable TMPDIR, if
47 -T is not specified. Default is /tmp.
48
49 Sort specification options (can be interspersed with column names):
50
51 -r or --descending
52 sort in reverse order (high to low)
53
54 -R or --ascending
55 sort in normal order (low to high)
56
57 -n or --numeric
58 sort numerically (default)
59
60 -N or --lexical
61 sort lexicographically
62
63 This module also supports the standard fsdb options:
64
65 -d Enable debugging output.
66
67 -i or --input InputSource
68 Read from InputSource, typically a file name, or "-" for standard
69 input, or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue
70 objects.
71
72 -o or --output OutputDestination
73 Write to OutputDestination, typically a file name, or "-" for
74 standard output, or (if in Perl) a IO::Handle, Fsdb::IO or
75 Fsdb::BoundedQueue objects.
76
77 --autorun or --noautorun
78 By default, programs process automatically, but Fsdb::Filter
79 objects in Perl do not run until you invoke the run() method. The
80 "--(no)autorun" option controls that behavior within Perl.
81
82 --help
83 Show help.
84
85 --man
86 Show full manual.
87
89 Input:
90 #fsdb name id test1
91 a 1 80
92 b 2 70
93 c 3 65
94 d 4 90
95 e 5 70
96 f 6 90
97
98 Command:
99 cat DATA/grades.fsdb | dbcolpercentile test1
100
101 Output:
102 #fsdb name id test1 percentile
103 d 4 90 1
104 f 6 90 1
105 a 1 80 0.66667
106 b 2 70 0.5
107 e 5 70 0.5
108 c 3 65 0.16667
109 # | dbsort -n test1
110 # | dbcolpercentile test1
111
112 Command 2:
113 cat DATA/grades.fsdb | dbcolpercentile --rank test1
114
115 Output 2:
116 #fsdb name id test1 rank
117 d 4 90 1
118 f 6 90 1
119 a 1 80 3
120 b 2 70 4
121 e 5 70 4
122 c 3 65 6
123 # | dbsort -n test1
124 # | dbcolpercentile --rank test1
125
127 Fsdb. dbcolhisto.
128
130 new
131 $filter = new Fsdb::Filter::dbcolpercentile(@arguments);
132
133 Create a new dbcolpercentile object, taking command-line arguments.
134
135 set_defaults
136 $filter->set_defaults();
137
138 Internal: set up defaults.
139
140 parse_options
141 $filter->parse_options(@ARGV);
142
143 Internal: parse command-line arguments.
144
145 setup
146 $filter->setup();
147
148 Internal: setup, parse headers.
149
150 _count_rows
151 $n = $self->_count_rows()
152
153 Interpose a filter on "$self-"{_in}> that counts the rows.
154
155 run
156 $filter->run();
157
158 Internal: run over each rows.
159
161 Copyright (C) 1991-2018 by John Heidemann <johnh@isi.edu>
162
163 This program is distributed under terms of the GNU general public
164 license, version 2. See the file COPYING with the distribution for
165 details.
166
167
168
169perl v5.32.0 2020-11-16 Fsdb::Filter::dbcolpercentile(3)