Skip to contents

Construct and validate utility objects.

The utility class

A utility object contains is an object that meets the following criteria:

  • It contains a column that acts as a unique respondent identifier and another that identifies different surveys over time.

  • It contains additional columns that represent the country, type and value of a utility that has previously been calculated.

  • Together, Each combination of respondent identifier, survey identifier, utility country and utility type should be unique and not duplicated across rows.

Usage

new_utility(x, respondentID, surveyID, country, type, value)

validate_utility(xx)

Arguments

x

[data.frame].

respondentID

[character] Unique respondent identifier. The name of a variable in x that uniquely identifies respondents.

surveyID

[character] Name of variable in x that uniquely identifies surveys over time. To avoid ambiguity the specified variable must be either numeric or a factor (in which case the order will be taken as that given by the factor levels).

country

[character] Name of variable in x representing the utility country.

type

[character] Name of variable in x representing the utility country.

value

[character] Name of variable in x representing the utility value.

xx

An R Object to validate.

Value

A utility object (invisibly for validate_utility()).

Details

new_utility() creates a utility object with minimal checking of the input arguments. It is mainly for developer use and should normally be accompanied by a call to validate_utility() which performs further checking of the underlying data.