Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Bin Data

The stats::frequency function categorizes the numerical data into a number of bins given by semiopen intervals (ai, bi]. This function returns a table with the entries (rows) corresponding to the bins. Each entry shows the following information:

  • The number of the bin

  • The interval defining the bin

  • The number of data in the bin

  • The data contained in the bin

The stats::frequency function enables you to specify the number of bins. By default, stats::frequency categorizes the data into 10 bins. For example, categorize the following data into 10 bins:

x := [-10.1, -1, 1.1, 3.5, 13, 0, -5.5, 0.5,
                   7.9, 15, 0.15, 6.7, 2, 9]:
stats::frequency(x)

Now, categorize the same data into 5 bins:

stats::frequency(x, 5)

When creating the bins, you can specify the intervals. For example, divide the data into two bins: one bin contains the numbers that are less or equal to zero, and the other bin contains the numbers that are greater than zero:

stats::frequency(x, [[-infinity, 0], [0, infinity]])

For graphical interpretation of the data binning, see Create Bar Charts, Histograms, and Pie Charts.

Was this topic helpful?