View source: R/functions_statistics.R
number_categories | R Documentation |
This function computes the total number of individuals being in a category of an attribute in a partition. It also computes the sum of the proportion in each group of individuals being in a category.
number_categories(partition, attribute, stat, category)
partition |
A partition (vector) |
attribute |
A vector containing the values of the attribute |
stat |
The statistic to compute : 'avg' for the sum of proportion per group and 'sum' for the total number |
category |
The category to consider or category = 'all' if all categories have to be considered |
The statisic chosen in stat depending on the value of category. If category = 'all', returns a vector.
p <- c(1,2,2,3,3,4,4,4,5)
at <- c(1,0,0,0,1,1,0,0,1)
number_categories(p,at,'avg','all')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.