count | R Documentation |
Counts values by rows/columns using a predicate function.
count(x, ...)
## S4 method for signature 'data.frame'
count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...)
## S4 method for signature 'matrix'
count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...)
x |
An R object (should be a |
... |
Further arguments to be passed to |
f |
A predicate |
margin |
A length-one |
negate |
A |
na.rm |
A |
A numeric
vector.
N. Frerebeau
Other data preparation tools:
append_column()
,
append_rownames()
,
assign()
,
compact()
,
detect()
,
discard()
,
get()
,
keep()
,
seek()
## Create a data matrix
X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5)
## Add NA
k <- sample(1:25, 3, FALSE)
X[k] <- NA
X
## Count missing values in rows
count(X, f = is.na, margin = 1)
## Count non-missing values in columns
count(X, f = is.na, margin = 2, negate = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.