survey: Create a new Survey

Description Usage Arguments Privat fields (R6) Public methods (R6) Note Author(s) Examples

View source: R/survey.R

Description

Create a new Survey from a data.frame, data.table or tbl. The class Survey provides additional private (hidden) fields pertaining to the Survey/data, but should otherwise behave like a regular data.frame.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

Arguments

x

A data.frame, data.table or tbl (requires dplyr).

Privat fields (R6)

labels

A label (question text) associated with a given variable in the data.

association

Specification of what the variable is associated with. This field is used to specify the structural model for the PLS-PM modelling, in addition to other variables of interest for an analysis.

config

This field keeps track of configurations made by the user when working on the Survey.

translations

A dictionary containing translations to be used when generating output based on Survey.

marketshares

The marketshares used for individual entities when producing weighted averages/counts from the Survey.

Public methods (R6)

new

Initialize a new Survey. Expects a data.frame, data.table or tbl as input.

do

Do arbitrary operations on the Survey. First argument should be the function, second a list of arguments for do.call.

get_data

Return a copy of the data.

model

Return a summary of the data for the Survey. This includes labels and associations, and the object (survey_model) prints nicely.

entities

This method produces a summary of the entities (total/valid observations and marketshare) if they have been specified.

Note

Under the hood, the Survey is a R6 class - this means that $ is reserved for accessing the public methods of the class, and not columns in the data directly. S3 methods are provided (and prefered) to make the Survey behave more like regular R objects.

Author(s)

Kristian D. Olsen

Examples

1
2
3
4
5
6
7
# Create a new survey (regular)
df <- survey_df(data.frame("A" = 1, "B" = 2))
dt <- survey_dt(data.frame("A" = 1, "B" = 2))

if (require(dplyr)) {
  tbl <- survey_tbl(data.frame("A" = 1, "B" = 2))
}

itsdalmo/reporttoolDT documentation built on May 18, 2019, 7:11 a.m.