spread_data: Spread Data

Description Usage Arguments Value Examples

Description

spread_data is written to work with functions from the revealedPrefs package.

checkWarp and similar "check" functions take as input two n by i matrices, one for goods and one for prices. spread_data takes a dataframe and returns a list with two matrices, which can then be passed into checkWarp and similar functions.

Usage

1

Arguments

df

a dataframe containing columns with quantities and prices of goods

...

the columns within df that contain quantities and prices. The first half of the columns provided are assumed to be quantities and the second half of the columns provided are be assumed to be prices.

Value

a list containg two matrices:

x

a matrix containing quantities

p

a matrix containing prices

Examples

1
2
3
4
5
# use simGarp and gather_data to create a sample df containing 4 observations and 6 columns (3 quantities and 3 prices)
df <- simGarp(4, 3) %>% gather_data()

# use spread_data to return a list of two matrices
spread_data(df, x1, x2, x3, p1, p2, p3)

naecker-lab/revealedPrefsExtra documentation built on June 14, 2019, 7:07 p.m.