dae (version 3.0-32)

fac.nested: creates a factor whose values are generated within those of the factor nesting.fac

Description

Creates a factor whose levels are generated within those of the factor nesting.fac. All elements of nesting.fac having the same level are numbered from 1 to the number of different elements having that level.

Usage

fac.nested(nesting.fac, levels=NA, labels=NA, ...)

Arguments

nesting.fac

The factor within each of whose levels the created factor is to be generated.

levels

Optional vector of levels for the factor. Any data value that does not match a value in levels will be NA in the factor. The default value of levels is the the list of numbers from 1 to the maximum replication of the levels of nesting.fac, represented as characters.

labels

Optional vector of values to use as labels for the levels of the factor. The default is as.character(levels).

...

Further arguments passed to the factor call dreating the new factor.

Value

A factor that is a character vector with class attribute "factor" and a levels attribute which determines what character strings may be included in the vector.

See Also

fac.gen in package dae, factor.

Examples

Run this code
# NOT RUN {
## set up factor A
A <- factor(c(1, 1, 1, 2, 2))

## create nested factor
B <- fac.nested(A)
# }

Run the code above in your browser using DataLab