data("Adult")
### Example 1: Manual decoding
### get code
code <- itemLabels(Adult)
head(code)
### get undecoded list and decode in a second step
list <- LIST(Adult[1:5], decode = FALSE)
list
decode(list, code = code)
### Example 2: Manually create an itemMatrix
data <- list(
c("income=small", "age=Young"),
c("income=large", "age=Middle-aged")
)
iM <- encode(data, code)
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, "education"]
itemLabels(sub)
image(sub)
### recode to match Adult again
sub.recoded <- recode(sub, match = Adult)
image(sub.recoded)
Run the code above in your browser using DataLab