Description Usage Arguments Details Value Examples
View source: R/create_covcor.R
Calculate the number of variables implied by a number of pairs.
1 | calc_nvars(npairs)
|
npairs |
Count, the number of pairs. |
When creating pairs of variables, e.g. for a correlation/covariance
matrix, the nb of variables nvars
implies a given number of
pairs npairs
. npairs
can be determined since
npairs = binomial{nvars}{2}
which gives
2 x nvars = npairs^2 - npairs
which is a quadratic equation that can
be resolved with npairs = (sqrt(1 - 4 x (-2 x nvars) + 1) / 2
.
Count, number of variables.
1 2 | nvars <- calc_nvars(6)
stopifnot(nvars == 4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.