View source: R/designs_helpers.R
index_z | R Documentation |
Index Z experimental design data. This function adds alternative id (AID) and / or choice set id (CID). This is an internal function which simplifies indexation of data during generation procedures with complex designs.
index_z(Z, alt_id = NULL, type = c("AID", "CID"))
Z |
Input data.frame object to be indexed |
alt_id |
Alternative id to be assigned to whole dataset. |
type |
"AID" or "CID". Specify the desired index to be added to the dataset. By default both "AID" and "CID" are added. This is an internal function which is used in data generation procedures. |
data.frame Indexed dataset Z.
# Create alternatives alt1 <- alternative$new() alt1$add_attributes(Quality = runif(min = 0, max = 1), Price = rnorm(mean = 5)) alt2 <- alternative$new() alt2$add_attributes(Size = runif(min = 0, max = 1), Price = rnorm(mean = 6)) # Regroup alternatives into design edesign <- experimental_design$new(alternatives = list(alt1, alt2)) Z <- designs_r(edesign, n = 1) # Idendex data frame Z <- index_z(Z, alt_id = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.