Domains: Domains

Description Usage Arguments Value Examples

Description

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.

Usage

1
Domains (y, domains, value)

Arguments

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

Value

A numeric vector, copy of y, with some values turned zero depending on values of domains and value

Examples

 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"))

Frames2 documentation built on May 2, 2019, 8:13 a.m.