| signcount | R Documentation |
This function counts the number of positive, negative and zero elements in a numeric vector or matrix,
including some types of dense and sparse representations in the Matrix package.
It can be used to test for non-negativity and compute nonzero counts efficiently, without any memory overhead.
signcount(x, what = c("counts", "nonneg", "nnzero"))
x |
a numeric vector or array, or a numeric |
what |
whether to return the counts of positive, negative and zero elements ( |
x must not contain any undefined values; signcount does not check whether this is actually the case.
what="counts"A labelled numeric vector of length 3 with the counts of positive (pos), zero (zero) and negative (neg) values.
what="nonneg"A single logical value: TRUE if x is non-negative, FALSE otherwise.
what="nonzero"A single numeric value, the total number of nonzero elements in x.
Stephanie Evert (https://purl.org/stephanie.evert)
signcount(DSM_TermTermMatrix) # dense matrix
signcount(DSM_TermContextMatrix) # sparse dgCMatrix
signcount(DSM_TermContextMatrix, "nonneg") # confirm that it is non-negative
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.