Learn R Programming

networkreporting (version 0.1.1)

add.kp: attach known populations to a dataframe

Description

take a known population vector (see df.to.kpvec) and associate it with a survey dataframe. this makes it more convenient to use some of the networksampling package's function

Usage

add.kp(survey.data, kp.vec, total.pop.size = NULL)

Arguments

survey.data
the survey dataframe
kp.vec
the known population vector
total.pop.size
(optional) the total population size to use (see below)

Value

the survey dataframe with the known population vector attached as an attribute

Details

The total.popn.size parameter is interpreted as follows:
  • NA if total.popn.size is NA then work with proportions
  • NULL if total.popn.size is NULL (nothing passed in), then assume that there's a total.popn.size attribute associated with the dataset we're using
  • numerical value if an actual total.popn.size was passed in, use that value

See Also

df.to.kpvec

Examples

Run this code
## Not run: 
# 
#   # if kp.dat is a dataframe with columns 'kp' with known popn names
#   # and 'total.size' with the total size,
#   # and my.survey is the dataframe with survey responses
# 
#   my.kp.vec <- df.to.kpvec(kp.data, kp.var='kp', kp.value='total.size')
#   my.survey <- add.kp(my.survey, my.kp.vec)
# 
#   # now we can call estimator functions like
#   # kp.degree.estimator without having to specify known
#   # populations each time
# ## End(Not run)

Run the code above in your browser using DataLab