Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

count_value

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

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

Rfast

A Collection of Efficient and Extremely Fast R Functions

v2.0.1
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Marios Dimitriadis, Stefanos Fafalios, Ioannis Tsamardinos, Matteo Fasiolo, Giorgos Borboudakis, John Burkardt, Changliang Zou, Kleanthi Lakiotaki and Christina Chatzipantsiou.
Initial release
2020-09-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.