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

View source: R/count_value.R

Row - Wise matrix/vector count the frequency of a value 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,cores = 0)
rowCountValues(x, values, parallel = FALSE,cores = 0)

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.

cores

Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE. Default value is 0 and it means the maximum supported cores.

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]
count_value(x,value)
y <- sample(letters,replace=TRUE)
value <- "r"
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

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.