mixgroup: Construct Grouped Data from Raw Data

Description Usage Arguments Value See Also Examples

View source: R/mixgroup.R

Description

Group raw data in the form of numbers of observations over successive intervals.

Usage

1
mixgroup(x, breaks = NULL, xname = NULL, k = NULL, usecondit = FALSE)

Arguments

x

a data frame or matrix containing raw data, whose first column should be the measurements to be grouped, and second column, if available, includes the numbers indicating which component each individual belongs to.

breaks

one of: * a vector giving the boundaries of intervals which raw data are grouped into, * a single number giving the number of intervals, * a character string naming an algorithm to compute the number of intervals, * a function to compute the number of intervals. In the last three cases the number is a suggestion only.

xname

the name of measurement.

k

the number of components.

usecondit

if usecondit is TRUE and x has two columns, then conditional data will be displayed with grouped data.

Value

A data frame containing grouped data derived from raw data, whose first column includes the right boundaries of grouping intervals, where the first and last intervals are open-ended; whose second column consists of the frequencies which are the numbers of observations falling into each interval. If usecondit is TRUE and the numbers indicating which component the individual comes from are available, conditional data which can be regarded as a table, whose element in row j and column i is the number of observations from the jth interval belonging to the ith component, will be displayed with grouped data.

See Also

hist for more information about the argument breaks, is.mixdata for checking the class of data sets, mixparam for organizing the parameter values, mixconstr for constructing constraints.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(pikeraw) # load raw data `pikeraw'
pikeraw # display the data set `pikeraw'
mixgroup(pikeraw) # group raw data
pikemd <- mixgroup(pikeraw, breaks = c(0, seq(19.75, 65.75, 2), 80))
plot(pikemd)
mixgroup(pikeraw, breaks = c(0, seq(19.75, 65.75, 2), 80), usecondit = TRUE, k = 5)
# construct grouped data associated with conditional data
mixgroup(pikeraw, usecondit = TRUE)
mixgroup(pikeraw, usecondit = TRUE, k = 3) # grouping data with a warning message
mixgroup(pikeraw, usecondit = TRUE, k = 8)

Example output

    length age
1     18.0   1
2     19.0   1
3     19.5   1
4     19.5   1
5     20.0   1
6     20.0   1
7     20.5   1
8     21.0   1
9     21.0   1
10    21.0   1
11    21.5   1
12    21.5   1
13    21.5   1
14    21.5   1
15    22.0   1
16    22.5   1
17    22.5   1
18    22.5   1
19    22.5   1
20    22.5   1
21    22.5   1
22    22.5   1
23    22.5   1
24    22.5   1
25    23.0   1
26    23.0   1
27    23.0   1
28    23.0   1
29    23.0   1
30    23.5   1
31    23.5   1
32    23.5   1
33    23.5   1
34    23.5   1
35    23.5   1
36    24.0   1
37    24.0   1
38    24.0   1
39    24.0   1
40    24.0   1
41    24.5   1
42    24.5   1
43    25.0   1
44    25.0   1
45    26.0   1
46    26.0   1
47    26.0   1
48    26.5   1
49    26.5   1
50    27.0   1
51    27.5   1
52    27.5   1
53    28.0   1
54    28.5   1
55    28.5   1
56    25.0   2
57    25.5   2
58    26.5   2
59    26.5   2
60    26.5   2
61    27.0   2
62    27.5   2
63    27.5   2
64    28.0   2
65    28.0   2
66    28.0   2
67    28.0   2
68    28.0   2
69    28.0   2
70    28.0   2
71    28.0   2
72    28.5   2
73    28.5   2
74    29.0   2
75    29.0   2
76    29.0   2
77    29.0   2
78    29.0   2
79    29.0   2
80    29.0   2
81    29.0   2
82    29.5   2
83    29.5   2
84    29.5   2
85    29.5   2
86    29.5   2
87    29.5   2
88    29.5   2
89    29.5   2
90    29.5   2
91    29.5   2
92    30.0   2
93    30.0   2
94    30.0   2
95    30.0   2
96    30.0   2
97    30.0   2
98    30.0   2
99    30.0   2
100   30.0   2
101   30.0   2
102   30.5   2
103   30.5   2
104   30.5   2
105   30.5   2
106   30.5   2
107   30.5   2
108   30.5   2
109   30.5   2
110   30.5   2
111   30.5   2
112   30.5   2
113   31.0   2
114   31.0   2
115   31.0   2
116   31.0   2
117   31.0   2
118   31.0   2
119   31.0   2
120   31.5   2
121   31.5   2
122   31.5   2
123   31.5   2
124   31.5   2
125   31.5   2
126   31.5   2
127   31.5   2
128   31.5   2
129   31.5   2
130   32.0   2
131   32.0   2
132   32.0   2
133   32.0   2
134   32.0   2
135   32.0   2
136   32.0   2
137   32.0   2
138   32.0   2
139   32.0   2
140   32.0   2
141   32.0   2
142   32.0   2
143   32.5   2
144   32.5   2
145   32.5   2
146   32.5   2
147   32.5   2
148   32.5   2
149   32.5   2
150   32.5   2
151   32.5   2
152   32.5   2
153   32.5   2
154   32.5   2
155   32.5   2
156   32.5   2
157   32.5   2
158   32.5   2
159   32.5   2
160   33.0   2
161   33.0   2
162   33.0   2
163   33.0   2
164   33.0   2
165   33.0   2
166   33.0   2
167   33.0   2
168   33.0   2
169   33.0   2
170   33.0   2
171   33.0   2
172   33.0   2
173   33.0   2
174   33.0   2
175   33.0   2
176   33.0   2
177   33.0   2
178   33.0   2
179   33.0   2
180   33.0   2
181   33.0   2
182   33.5   2
183   33.5   2
184   33.5   2
185   33.5   2
186   33.5   2
187   33.5   2
188   33.5   2
189   33.5   2
190   33.5   2
191   33.5   2
192   33.5   2
193   33.5   2
194   33.5   2
195   33.5   2
196   33.5   2
197   33.5   2
198   34.0   2
199   34.0   2
200   34.0   2
201   34.0   2
202   34.0   2
203   34.0   2
204   34.0   2
205   34.0   2
206   34.0   2
207   34.0   2
208   34.0   2
209   34.0   2
210   34.0   2
211   34.0   2
212   34.5   2
213   34.5   2
214   34.5   2
215   34.5   2
216   34.5   2
217   34.5   2
218   34.5   2
219   34.5   2
220   34.5   2
221   34.5   2
222   34.5   2
223   34.5   2
224   34.5   2
225   34.5   2
226   34.5   2
227   34.5   2
228   35.0   2
229   35.0   2
230   35.0   2
231   35.0   2
232   35.0   2
233   35.0   2
234   35.0   2
235   35.0   2
236   35.0   2
237   35.0   2
238   35.0   2
239   35.0   2
240   35.0   2
241   35.0   2
242   35.0   2
243   35.0   2
244   35.0   2
245   35.0   2
246   35.0   2
247   35.5   2
248   35.5   2
249   35.5   2
250   35.5   2
251   35.5   2
252   35.5   2
253   35.5   2
254   35.5   2
255   35.5   2
256   35.5   2
257   35.5   2
258   35.5   2
259   35.5   2
260   35.5   2
261   36.0   2
262   36.0   2
263   36.5   2
264   36.5   2
265   36.5   2
266   36.5   2
267   36.5   2
268   36.5   2
269   36.5   2
270   37.0   2
271   37.0   2
272   37.0   2
273   37.0   2
274   37.0   2
275   37.5   2
276   37.5   2
277   37.5   2
278   37.5   2
279   37.5   2
280   37.5   2
281   37.5   2
282   37.5   2
283   37.5   2
284   38.0   2
285   38.0   2
286   38.0   2
287   38.0   2
288   38.0   2
289   38.0   2
290   38.5   2
291   38.5   2
292   38.5   2
293   39.0   2
294   39.5   2
295   39.5   2
296   39.5   2
297   40.5   2
298   41.5   2
299   31.0   3
300   32.0   3
301   32.5   3
302   34.5   3
303   35.0   3
304   35.5   3
305   35.5   3
306   35.5   3
307   35.5   3
308   35.5   3
309   35.5   3
310   36.0   3
311   36.0   3
312   36.0   3
313   36.5   3
314   36.5   3
315   36.5   3
316   36.5   3
317   36.5   3
318   37.0   3
319   37.0   3
320   37.0   3
321   37.0   3
322   37.0   3
323   37.5   3
324   37.5   3
325   37.5   3
326   37.5   3
327   37.5   3
328   37.5   3
329   37.5   3
330   37.5   3
331   38.0   3
332   38.0   3
333   38.0   3
334   38.5   3
335   38.5   3
336   38.5   3
337   38.5   3
338   38.5   3
339   38.5   3
340   38.5   3
341   38.5   3
342   39.0   3
343   39.0   3
344   39.0   3
345   39.0   3
346   39.0   3
347   39.0   3
348   39.0   3
349   39.0   3
350   39.0   3
351   39.0   3
352   39.0   3
353   39.5   3
354   39.5   3
355   39.5   3
356   39.5   3
357   39.5   3
358   39.5   3
359   39.5   3
360   40.0   3
361   40.0   3
362   40.0   3
363   40.0   3
364   40.0   3
365   40.0   3
366   40.0   3
367   40.0   3
368   40.0   3
369   40.0   3
370   40.0   3
371   40.0   3
372   40.5   3
373   40.5   3
374   40.5   3
375   40.5   3
376   40.5   3
377   40.5   3
378   41.0   3
379   41.0   3
380   41.0   3
381   41.0   3
382   41.0   3
383   41.0   3
384   41.0   3
385   41.0   3
386   41.0   3
387   41.0   3
388   41.0   3
389   41.5   3
390   41.5   3
391   41.5   3
392   41.5   3
393   41.5   3
394   42.0   3
395   42.0   3
396   42.0   3
397   42.0   3
398   42.5   3
399   42.5   3
400   42.5   3
401   42.5   3
402   42.5   3
403   42.5   3
404   42.5   3
405   42.5   3
406   42.5   3
407   42.5   3
408   43.0   3
409   43.0   3
410   43.0   3
411   43.0   3
412   43.0   3
413   43.5   3
414   43.5   3
415   43.5   3
416   43.5   3
417   44.0   3
418   44.0   3
419   44.0   3
420   44.0   3
421   44.5   3
422   44.5   3
423   44.5   3
424   44.5   3
425   45.0   3
426   45.0   3
427   45.0   3
428   45.0   3
429   45.0   3
430   45.0   3
431   45.5   3
432   45.5   3
433   46.0   3
434   46.5   3
435   46.5   3
436   46.5   3
437   46.5   3
438   47.0   3
439   47.5   3
440   48.0   3
441   48.0   3
442   48.0   3
443   48.5   3
444   48.5   3
445   48.5   3
446   50.0   3
447   50.0   3
448   50.5   3
449   51.0   3
450   51.5   3
451   52.0   3
452   52.5   3
453   52.5   3
454   53.0   3
455   44.5   4
456   44.5   4
457   44.5   4
458   45.0   4
459   45.5   4
460   45.5   4
461   46.0   4
462   46.0   4
463   46.0   4
464   47.0   4
465   47.0   4
466   47.5   4
467   47.5   4
468   47.5   4
469   47.5   4
470   47.5   4
471   48.0   4
472   48.5   4
473   48.5   4
474   48.5   4
475   49.5   4
476   50.0   4
477   50.0   4
478   50.5   4
479   51.0   4
480   51.5   4
481   51.5   4
482   51.5   4
483   52.0   4
484   52.5   4
485   53.0   4
486   53.5   4
487   54.0   4
488   54.5   4
489   55.0   4
490   55.0   4
491   55.0   4
492   55.5   4
493   55.5   4
494   55.5   4
495   56.0   4
496   56.0   4
497   58.5   4
498   61.0   4
499   61.0   4
500   62.5   4
501   64.5   4
502   49.5   5
503   52.0   5
504   52.0   5
505   53.5   5
506   56.5   5
507   58.5   5
508   58.5   5
509   58.5   5
510   59.0   5
511   59.5   5
512   60.0   5
513   61.0   5
514   61.0   5
515   61.0   5
516   62.5   5
517   62.5   5
518   65.0   5
519   67.5   5
520   68.5   5
521   71.0   5
522   75.0   5
523   76.5   5
   length count
1      20     6
2      25    39
3      30    56
4      35   150
5      40   118
6      45    65
7      50    37
8      55    24
9      60    13
10     65    10
11     70     2
12     75     2
13    Inf     1
   length count C1 C2 C3 C4 C5
1   19.75     4  4  0  0  0  0
2   21.75    10 10  0  0  0  0
3   23.75    21 21  0  0  0  0
4   25.75    11  9  2  0  0  0
5   27.75    14  8  6  0  0  0
6   29.75    31  3 28  0  0  0
7   31.75    39  0 38  1  0  0
8   33.75    70  0 68  2  0  0
9   35.75    71  0 63  8  0  0
10  37.75    44  0 23 21  0  0
11  39.75    42  0 13 29  0  0
12  41.75    36  0  2 34  0  0
13  43.75    23  0  0 23  0  0
14  45.75    22  0  0 16  6  0
15  47.75    17  0  0  7 10  0
16  49.75    12  0  0  6  5  1
17  51.75    12  0  0  5  7  0
18  53.75    11  0  0  4  4  3
19  55.75     8  0  0  0  8  0
20  57.75     3  0  0  0  2  1
21  59.75     6  0  0  0  1  5
22  61.75     6  0  0  0  2  4
23  63.75     3  0  0  0  1  2
24  65.75     2  0  0  0  1  1
25    Inf     5  0  0  0  0  5
   length count C1  C2 C3 C4 C5
1      20     6  6   0  0  0  0
2      25    39 38   1  0  0  0
3      30    56 11  45  0  0  0
4      35   150  0 145  5  0  0
5      40   118  0  50 68  0  0
6      45    65  0   2 59  4  0
7      50    37  0   0 17 19  1
8      55    24  0   0  7 14  3
9      60    13  0   0  0  6  7
10     65    10  0   0  0  4  6
11     70     2  0   0  0  0  2
12     75     2  0   0  0  0  2
13    Inf     1  0   0  0  0  1
   length count C1  C2 C3 C4 C5
1      20     6  6   0  0  0  0
2      25    39 38   1  0  0  0
3      30    56 11  45  0  0  0
4      35   150  0 145  5  0  0
5      40   118  0  50 68  0  0
6      45    65  0   2 59  4  0
7      50    37  0   0 17 19  1
8      55    24  0   0  7 14  3
9      60    13  0   0  0  6  7
10     65    10  0   0  0  4  6
11     70     2  0   0  0  0  2
12     75     2  0   0  0  0  2
13    Inf     1  0   0  0  0  1
Warning message:
In mixgroup(pikeraw, usecondit = TRUE, k = 3) :
  5 groups found, argument k = 3 ignored
   length count C1  C2 C3 C4 C5 C6 C7 C8
1      20     6  6   0  0  0  0  0  0  0
2      25    39 38   1  0  0  0  0  0  0
3      30    56 11  45  0  0  0  0  0  0
4      35   150  0 145  5  0  0  0  0  0
5      40   118  0  50 68  0  0  0  0  0
6      45    65  0   2 59  4  0  0  0  0
7      50    37  0   0 17 19  1  0  0  0
8      55    24  0   0  7 14  3  0  0  0
9      60    13  0   0  0  6  7  0  0  0
10     65    10  0   0  0  4  6  0  0  0
11     70     2  0   0  0  0  2  0  0  0
12     75     2  0   0  0  0  2  0  0  0
13    Inf     1  0   0  0  0  1  0  0  0

mixdist documentation built on May 2, 2019, 3:34 p.m.

Related to mixgroup in mixdist...