row_count() mimics base R's
rowSums(), with sums
for a specific value indicated by
count. Hence, it is equivalent
rowSums(x == count, na.rm = TRUE). However, this function
is designed to work nicely within a pipe-workflow and allows select-helpers
for selecting variables and the return value is always a data frame
(with one variable).
col_count() does the same for columns. The return value is
a data frame with one row (the column counts) and the same number
of columns as
1 2 3
A vector or data frame.
Optional, unquoted names of variables that should be selected for
further processing. Required, if
The value for which the row or column sum should be computed. May
be a numeric value, a character string (for factors or character vectors),
Name of new the variable with the row or column counts.
row_count(), a data frame with one variable: the sum of
appearing in each row of
col_count(), a data frame with
one row and the same number of variables as in
x: each variable
holds the sum of
count appearing in each variable of
append = TRUE,
x including this variable will be returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
dat <- data.frame( c1 = c(1, 2, 3, 1, 3, NA), c2 = c(3, 2, 1, 2, NA, 3), c3 = c(1, 1, 2, 1, 3, NA), c4 = c(1, 1, 3, 2, 1, 2) ) row_count(dat, count = 1, append = FALSE) row_count(dat, count = NA, append = FALSE) row_count(dat, c1:c3, count = 2, append = TRUE) col_count(dat, count = 1, append = FALSE) col_count(dat, count = NA, append = FALSE) col_count(dat, c1:c3, count = 2, append = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.