View source: R/diary_functions.R
ngrp | R Documentation |
ngrp
computes the number of groups in data given one or more grouping
variables. This is simply a combination of unique.data.frame
+
nrow
.
ngrp(data, grp.nm)
data |
data.frame of data. |
grp.nm |
character vector of colnames from |
integer vector of length 1 specifying the number of groups.
nrow_ml
ncases_ml
nrow_by
ncases_by
# one grouping variable
Orthodont2 <- as.data.frame(nlme::Orthodont)
ngrp(Orthodont2, grp.nm = "Subject")
length(unique(Orthodont2$"Subject"))
# two grouping variable
co2 <- as.data.frame(CO2)
ngrp(co2, grp.nm = c("Plant"))
grp_nm <- c("Type","Treatment")
ngrp(co2, grp.nm = grp_nm)
unique.data.frame(co2[grp_nm])
#TODO: how does it handle factor levels with no cases?
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.