as.rds.data.frame: Coerces a data.frame object into an rds.data.frame object.

Description Usage Arguments Value Examples

View source: R/rds.data.frame.R

Description

This function converts a regular R data frame into an rds.data.frame. The greatest advantage of this is that it performs integrity checks and will fail if the recruitment information in the original data frame is incomplete.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as.rds.data.frame(df, id = if (is.null(attr(df, "id"))) "id" else attr(df,
  "id"), recruiter.id = if (is.null(attr(df, "recruiter.id"))) {    
  "recruiter.id" } else attr(df, "recruiter.id"), network.size = if
  (is.null(attr(df, "network.size.variable"))) {     "network.size.variable" }
  else attr(df, "network.size.variable"), population.size = if
  (all(is.na(get.population.size(df, FALSE)))) {     NULL } else
  get.population.size(df, FALSE), max.coupons = if (is.null(attr(df,
  "max.coupons"))) {     NULL } else attr(df, "max.coupons"), notes = if
  (is.null(attr(df, "notes"))) {     NULL } else attr(df, "time"), time = if
  (is.null(attr(df, "time"))) {     NULL } else attr(df, "time"),
  check.valid = TRUE)

Arguments

df

A data.frame representing an RDS sample.

id

The unique identifier.

recruiter.id

The unique identifier of the recruiter of this row.

network.size

The number of alters (i.e. possible recruitees).

population.size

The size of the population from which this RDS sample has been drawn. Either a single number, or a vector of length three indicating low, mid and high estimates.

max.coupons

The number of recruitment coupons distributed to each enrolled subject (i.e. the maximum number of recruitees for any subject).

notes

Data set notes.

time

the name of the recruitment time variable. optional.

check.valid

If true, validity checks are performed to ensure that the data is well formed.

Value

An rds.data.frame object

Examples

1
2
3
dat <- data.frame(id=c(1,2,3,4,5), recruiter.id=c(2,-1,2,-1,4),
                  network.size.variable=c(4,8,8,2,3))
as.rds.data.frame(dat)

RDS documentation built on Dec. 2, 2017, 1:08 a.m.

Related to as.rds.data.frame in RDS...