ez.count: Count the occurrence of a single value in data frame...

View source: R/frame.R

ez.countR Documentation

Count the occurrence of a single value in data frame columnwise, or rowwise, or both

Description

count within one or more than one columns/rows, or entire data frame (ie, all columns/rows)

Usage

ez.count(x, val = NA, col = NULL, dim = 3)

Arguments

x

data frame or vector, if vector, parameters col, dim are ignored

val

value to be counted, could be NA. Note, may not differentiate 5.0 and 5, ie. 5.0==5 TRUE

col

column evaluated by eval('dplyr::select()'), single or vector. If NULL, all columns used

dim

1=along row (rowwise), 2=along col (colwse), 3=area, both, grand total (within specified cols/rows)

Value

returns a data frame, if dim=1/2; a single value if dim=3.
vector input x always outputs a single value.

See Also

ez.countif

Examples

sx = c("F", "F", "F", "M", "M", "M")
ht = c(69, 64, 67, 68, 72, 71)
wt = c(148, 132, 142, 149, 167, 165)
people = data.frame(sx, ht, wt)
ez.count(people,'M',dim=2)

jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.