Description Usage Arguments Value Examples
Given a main vector, an auxiliary one and a value of the latter, identifies positions of the auxiliary vector corresponding to values other than the given one. Then, turns zero values of the main vector corresponding to these positions.
1 | Domains (y, domains, value)
|
y |
A numeric main vector of size n |
domains |
A numeric/character/logic auxiliary vector of size n |
value |
A value of the auxiliary vector |
A numeric vector, copy of y
, with some values turned zero depending on values of domains
and value
1 2 3 4 5 6 7 8 9 10 11 12 | ########## Example 1 ##########
U <- c(13, 18, 20, 14, 9)
#Let build an auxiliary vector indicating whether values in U are above or below the mean.
aux <- c("Below", "Above", "Above", "Below", "Below")
#Now, only values below the mean remain, the other ones are turned zero.
Domains (U, aux, "Below")
########## Example 2 ##########
data(DatA)
attach(DatA)
#Let calculate total feeding expenses corresponding to households in domain a.
sum (Domains (Feed, Domain, "a"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.