pop2prof: Population to profiles

Description Usage Arguments Details Value See Also Examples

View source: R/pop2prof.R

Description

Extract from a population the observed profiles and their frequencies.

Usage

1
pop2prof(y, labtype = c("profiles", "progressive"))

Arguments

y

an observations matrix, used to count the profiles frequencies. See details.

labtype

the user can choose the type of labels to assign to the profiles. See details.

Details

The parameter y is a data.frame of observation of the ordinal or numeric variables. It is important that the order is defind into the object type, in order to build the incidence matrix (see getzeta).

The function estracts from the population the variables and their observed modalities, from them, it builds all the possible profiles and it assign them the frequencies. Note that, if some modalities are not observed their will not used to build the profiles. Therefore, this function shuld be used only if the variables definition has to be detected from the population, otherwise the function var2prof has to be used.

The user can choose the type label to assign to profiles. profiles is the combination of modailties that identify the profiles. When the names of the modalities are long, it is better to choose progressive, that assign to each profile a progressive number preceded by the letter "P".

Value

The function returns an object of S3 class wprof, "weighted profiles", which contains the data.frame named profiles and the vector of frequencies freq.

See Also

var2prof, getzeta

Examples

1
2
3
4
5
6
7
8
n <- 5
v1 <- as.ordered(c("a", "b", "c", "d"))
v2 <- 1:3
pop <- data.frame(
    v1 = sample(v1, n, replace = TRUE),
    v2 = sample(v2, n, replace = TRUE)
)
pop2prof(pop)

Example output

$profiles
    v1 v2
a/1  a  1
b/1  b  1
b/2  b  2
d/3  d  3

$freq
a/1 b/1 b/2 d/3 
  1   1   2   1 

attr(,"class")
[1] "wprof"

parsec documentation built on May 2, 2019, 6:08 p.m.