# NOT RUN {
## Assume we have a dataset:
data(Cars93, package="MASS")
mf <- mutaframe(Cars93)
mf$.color <- "gray"
## First step is to create a base selection
sel <- ItemSelection()
## Now, link that selection to other cases in same dataset by some variable
linked_sel <- sel$link(match_any_linker(Cars93["Manufacturer"]))
## Finally, scale that linked selection to the data
linked_sel$scale(function(x, d) {
d[as.logical(x), ".color"] <- "red"
}, mf)
## To test, select some cases
cases <- rep(FALSE, nrow(mf))
cases[seq(1, 10, 2)] <- TRUE
sel$replace(cases)
# }
Run the code above in your browser using DataLab