Learn R Programming

nmm (version 0.9)

add_variable: add_variable adds columns to the data matrix

Description

add_variable adds columns to the data matrix

Usage

add_variable(data = data, dname = "chc", weights = NULL)

Arguments

data

data.frame, if dname=="chc" columns "chc_i" has to be in the data.

dname

if dname=="chc" (dummy for chosen alternative) dummy for the choice alternative added, if "weights" weights added

weights

Matrix with weights to be added to the data

Value

data.frame

Examples

Run this code
# NOT RUN {
chc <- c(1,2,1,4,3,1,4)
data <- data.frame(choice=chc, x=rnorm(length(chc)), y=rnorm(length(chc)))
add_variable(data, dname="chc")
ww <- c(1,1,1,2,2,2,3)
add_variable(data, dname="weights", weights=ww)
# }

Run the code above in your browser using DataLab