add.kp: attach known populations to a dataframe

View source: R/helper_functions.r

add.kpR Documentation

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 functions

Usage

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

Arguments

survey.data

the survey dataframe

kp.vec

the known population vector

total.popn.size

(optional) the total population size to use (see below)

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

Value

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

See Also

df.to.kpvec

Examples

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

dfeehan/networkreporting documentation built on May 17, 2023, 1:06 a.m.