#r #cjoint
Вопрос:
используя R
пакет cjoint
, у меня есть conjointDesign
объект класса a (см. Ниже), из которого я хотел бы извлечь отдельные профили в виде data.frame.
Рассмотрим этот пример (взятый из cjoint
примеров)
library(cjoint) data("immigrationconjoint") ## construct the conjoint design manually in in R attribute_list lt;- list() attribute_list[["Education"]] lt;-c("no formal","4th grade", "8th grade","high school", "two-year college","college degree", "graduate degree") attribute_list[["Gender"]] lt;- c("female","male") attribute_list[["Country of Origin"]] lt;- c("Germany","France","Mexico", "Philippines","Poland","India", "China","Sudan","Somalia","Iraq") attribute_list[["Reason for Application"]] lt;- c("reunite with family", "seek better job", "escape persecution") attribute_list[["Job"]] lt;- c("janitor","waiter","child care provider", "gardener","financial analyst", "construction worker","teacher", "computer programmer","nurse", "research scientist","doctor") immigrationdesign lt;- makeDesign(type='constraints', attribute.levels=attribute_list, constraints=constraint_list)
По сути, мне нужен фрейм данных, в котором каждая строка содержит один профиль, а каждый столбец-один уровень атрибутов, например:
# Education Gender Country of Origin Reason for Application Job 1 no formal Male France reunite with family janitor 2 no formal Female Sudan seek better job waiter 3 graduate degree Female India escape persecution doctor 4 8th grade Male China reunite with family nurse ... etc ...
Я пытался конвертировать as.data.frame()
, но безрезультатно; кто-нибудь знает, как это сделать? Заранее спасибо!