R: Row - Wise matrix/vector count the frequency of a value

Row - Wise matrix/vector count the frequency of a value {Rfast} | R Documentation

## Row - Wise matrix/vector count the frequency of a value

### Description

Row - Wise matrix/vector count the frequency of a value.

### Usage

    count_value(x, value)
    colCountValues(x, values, parallel = FALSE)
    rowCountValues(x, values, parallel = FALSE)

### Arguments

`x` | A vector with the data (numeric or character) or a numeric matrix.
`value` | The value, numeric or character, to check its frequency in the vector "x".
`values` | a vector with the values to check its frequency in the matrix "x" by row or column.
`parallel` | Do you want to do it in parallel in C++? TRUE or FALSE. Works with every other argument.

### Details

The functions is written in C++ in order to be as fast as possible. The "x" and "value" must have the same type. The type can be numeric or character.

### Value

The frequency of a value/values in a vector in linear time or by row/column in a matrix.

### Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

### See Also

`Median, binary_search, Order, nth`

### Examples

    x <- rnorm(100)
    value <- x[50]
    system.time( count_value(x,value) )
    y <- sample(letters,replace=TRUE)
    value <- "r"
    system.time( count_value(y,value) )
    values <- sample(x,100,replace=TRUE)
    x <- matrix(x,100,100)
    res<-colCountValues(x,values)
    res<-rowCountValues(x,values)
    x<-value<-values<-y<-NULL

[Package Rfast version 2.0.0 Index]