# NOT RUN {
data("Adult")
## Example 1: Manual decoding
## get code
iLabels <- itemLabels(Adult)
head(iLabels)
## get undecoded list and decode in a second step
list <- LIST(Adult[1:5], decode = FALSE)
list
decode(list, itemLabels = iLabels)
## Example 2: Manually create an itemMatrix
data <- list(
c("income=small", "age=Young"),
c("income=large", "age=Middle-aged")
)
iM <- encode(data, iLabels)
iM
inspect(iM)
## use the itemMatrix to create transactions
as(iM, "transactions")
## Example 3: use recode
## select first 100 transactions and all education-related items
sub <- Adult[1:100, itemInfo(Adult)$variables == "education"]
itemLabels(sub)
image(sub)
## recode to match Adult again
sub.recoded <- recode(sub, match = Adult)
image(sub.recoded)
## Example 4: manually create 2 new transaction for the Adult data set
## Note: check itemLabels(Adult) to see the available labels for items
twoTransactions <- as(encode(list(
c("age=Young", "relationship=Unmarried"),
c("age=Senior")
), itemLabels = itemLabels(Adult)),
"transactions")
inspect(twoTransactions)
## Example 5: manually create a rule and calculate interest measures
aRule <- new("rules",
lhs = encode(list(c("age=Young", "relationship=Unmarried")),
itemLabels = itemLabels(Adult)),
rhs = encode(list(c("income=small")),
itemLabels = itemLabels(Adult))
)
quality(aRule) <- interestMeasure(aRule,
measure = c("support", "confidence", "lift"), transactions = Adult)
inspect(aRule)
# }
Run the code above in your browser using DataLab