fcount | R Documentation |
A much faster replacement for dplyr::count
.
fcount(x, ..., w = NULL, name = "N", add = FALSE,
sort = FALSE, decreasing = FALSE)
fcountv(x, cols = NULL, w = NULL, name = "N", add = FALSE,
sort = FALSE, ...)
x |
a data frame or list-like object, including 'grouped_df' or 'indexed_frame'. Atomic vectors or matrices can also be passed, but will be sent through |
... |
for |
cols |
select columns to count cases by, using column names, indices, a logical vector or a selector function (e.g. |
w |
a numeric vector of weights, may contain missing values. In |
name |
character. The name of the column containing the count or sum of weights. |
add |
|
sort , decreasing |
arguments passed to |
If x
is a list, an object of the same type as x
with a column (name
) added at the end giving the count. Otherwise, if x
is atomic, a data frame returned from qDF(x)
with the count column added. By default (add = FALSE
) only the unique rows of x
of the columns used for counting are returned.
GRPN
, fnobs
, fndistinct
, Fast Grouping and Ordering, Collapse Overview
fcount(mtcars, cyl, vs, am)
fcountv(mtcars, cols = .c(cyl, vs, am))
fcount(mtcars, cyl, vs, am, sort = TRUE)
fcount(mtcars, cyl, vs, am, add = TRUE)
fcount(mtcars, cyl, vs, am, add = "group_vars")
## With grouped data
mtcars |> fgroup_by(cyl, vs, am) |> fcount()
mtcars |> fgroup_by(cyl, vs, am) |> fcount(add = TRUE)
mtcars |> fgroup_by(cyl, vs, am) |> fcount(add = "group_vars")
## With indexed data: by default counting on the first index variable
wlddev |> findex_by(country, year) |> fcount()
wlddev |> findex_by(country, year) |> fcount(add = TRUE)
# Use fcountv to pass additional arguments to GRP.pdata.frame,
# here using the effect argument to choose a different index variable
wlddev |> findex_by(country, year) |> fcountv(effect = "year")
wlddev |> findex_by(country, year) |> fcountv(add = "group_vars", effect = "year")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.