price_prep: Rename variables as prices

View source: R/price_prep.R

price_prepR Documentation

Rename variables as prices

Description

This function helps users efficiently rename their variables as prices. At the same time, it will return only the variables required for purchase task processing: the unique identifier and the purchase task variables themselves.

Usage

price_prep(pt, id_var, vars, prices)

Arguments

pt

A data frame which includes the 'id_var' and purchase task variables.

id_var

The name of the unique identifier (ID) as identified in the data frame.

vars

The variable names of the purchase task items.

prices

The prices associated with each purchase task item in the same order as the 'vars'.

Value

A data frame consisting of variables 'vars' renamed as 'prices', as well as 'id_var'.

Examples

### --- Load Data
data("cpt_data")

### --- Function Example
pt <- price_prep(cpt_data, id_var = "ID", vars = c(paste0("cpt",1:15)),
prices = c("0","0.05","0.10","0.20","0.30","0.40","0.50","0.75","1","2","3","4","5","7.5","10"))


PBCAR/PThelper documentation built on May 13, 2024, 3:45 p.m.