I tried to rewrite this code (to learn this approach), using %>% operator:
library(arules)
data(AdultUCI) #https://archive.ics.uci.edu/ml/datasets/Census+Income
AdultUCI[["capital-gain"]] <- ordered(cut(AdultUCI[["capital-gain"]],
+ c(-Inf, 0, median(AdultUCI[["capital-gain"]][AdultUCI
+ [["capital-gain"]] > 0]), Inf)),
+ labels = c("None", "Low", "High"))
Is it possible to do? Here is my attempt:
AdultUCI[["capital-gain"]] <- ordered %>% cut %>% AdultUCI[["capital-gain"]],
+ c(-Inf, 0, median(AdultUCI[["capital-gain"]][AdultUCI[["capital-gain"]] > 0]),
+ Inf),labels = c("None", "Low", "High")