function in R Language is used to count the frequency of occurrence of a element in the vector. This function checks for each element in the vector and returns the number of times it occurs in the vector. It will create a vector of the length of the maximum element present in the vector.**tabulate()**

Syntax:tabulate(x, nbins)

Parameters:

x:Numeric Vector

nbins:to control length of output vector

**Example 1:**

`# R program to count frequency ` `# of elements in a vector ` ` ` `# Creating a vector ` `x1 <` `-` `c(` `3` `, ` `5` `, ` `3` `, ` `7` `, ` `9` `, ` `4` `, ` `6` `) ` `x2 <` `-` `c(` `-` `1` `, ` `-` `4` `, ` `2.4` `, ` `6` `, ` `-` `7` `) ` ` ` `# Calling tabulate() function ` `tabulate(x1) ` `tabulate(x2) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 0 0 2 1 1 1 1 0 1 [1] 0 1 0 0 0 1

Here, in the above code, the tabulate() function has ignored the negative values in the second vector, because it works only on numbers which are positive integers.

**Example 2:**

`# R program to count frequency ` `# of elements in a vector ` ` ` `# Creating a vector ` `x1 <` `-` `c(` `3` `, ` `5` `, ` `3` `, ` `7` `, ` `9` `, ` `4` `, ` `6` `) ` `x2 <` `-` `c(` `-` `1` `, ` `-` `4` `, ` `2.6` `, ` `6` `, ` `-` `7` `, ` `35` `) ` ` ` `# Calling tabulate() function ` `tabulate(x1, nbins ` `=` `4` `) ` `tabulate(x2, nbins ` `=` `8` `) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 0 0 2 1 [1] 0 1 0 0 0 1 0 0

Here, in the above code, the length of the output vector is limited by the nbins passed as argument.

## Recommended Posts:

- Check if an Object is of Type Numeric in R Programming - is.numeric() Function
- Get the Sign of Elements of a Numeric Vector in R Programming - sign() Function
- Convert Factor to Numeric and Numeric to Factor in R Programming
- Compute the gamma value of a Non-negative Numeric Vector in R Programming - gamma() Function
- Return the Index of the First Minimum Value of a Numeric Vector in R Programming - which.min() Function
- Return the Index of the First Maximum Value of a Numeric Vector in R Programming - which.max() Function
- Binning a Numeric Vector in R Programming - .bincode() Function
- Adding Noise to a Numeric Vector in R Programming - jitter() Function
- Convert an Object into a Vector in R Programming - as.vector() Function
- Check for the Existence of a Vector Object in R Programming - is.vector() Function
- Create a Vector of Colors from a Vector of Gray Levels in R Programming - gray() or grey() Function
- Check if a numeric value falls between a range in R Programming - between() function
- Calculate Cumulative Product of a Numeric Object in R Programming – cumprod() Function
- Calculate Cumulative Sum of a Numeric Object in R Programming - cumsum() Function
- Compute the Hyperbolic arctangent of numeric data in R Programming - atanh() Function
- Compute the beta value of Non-Negative Numeric Vectors in R Programming - beta() Function
- Get the natural logarithm of the beta value of Non-Negative numeric vectors in R Language - lbeta() Function
- Compute the Hyperbolic arcsine of numeric data in R Programming – asinh() Function
- Compute the Hyperbolic arccosine of numeric data in R Programming – acosh() Function
- Convert a Data Frame into a Numeric Matrix in R Programming - data.matrix() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.