View source: R/diary_functions.R
nrow_by | R Documentation |
nrow_by
computes the nrow of a data.frame by group. nrow_by
is
simply a wrapper for nrow
+ agg_dfm
.
nrow_by(data, grp.nm, sep = ".")
data |
data.frame of data. |
grp.nm |
character vector of colnames from |
sep |
character vector of length 1 specifying what string to use to
separate the groups when naming the return object. |
atomic vector with names = unique(interaction(data[grp.nm], sep
= sep))
and length = length(unique(interaction(data[grp.nm], sep =
sep)))
providing the nrow for each group.
ncases_by
nrow
agg_dfm
# one grouping variables
tmp_nm <- c("outcome","case","session","trt_time")
dat <- as.data.frame(lmeInfo::Bryant2016)[tmp_nm]
stats_by <- psych::statsBy(dat,
group = "case") # requires you to include "case" column in dat
nrow_by(data = dat, grp.nm = "case")
dat2 <- as.data.frame(ChickWeight)
nrow_by(data = dat2, grp.nm = "Chick")
# two grouping variables
tmp <- reshape(psych::bfi[1:10, ], varying = 1:25, timevar = "item",
ids = row.names(psych::bfi)[1:10], direction = "long", sep = "")
tmp_nm <- c("id","item","N","E","C","A","O") # Roxygen runs the whole script
dat3 <- str2str::stack2(tmp[tmp_nm], select.nm = c("N","E","C","A","O"),
keep.nm = c("id","item"))
nrow_by(dat3, grp.nm = c("id","vrb_names"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.