で
ありがとうございます。このようなあなたのデータセットからのトランザクションを作成することができます。
library(dplyr)
をこの関数はID_Order
でID_Order
concat <- function(x) {
return(list(as.character(x)))
}
グループdf
あたりのトランザクションを取得するために使用され、連結する。 pull()
は、連結されたModel
をリストに返します。 ID_Order
へ
a_list <- df %>%
group_by(ID_Order) %>%
summarise(concat = concat(Model)) %>%
pull(concat)
セット名:
names(a_list) <- unique(df$ID_Order)
次に、あなたがパッケージarules
使用することができます。transactions
クラスの
のGetオブジェクト:
transactions <- as(a_list, "transactions")
抽出ルールを。 supp
とconf
respに最小サポートと最小信頼を設定できます。
inspect(rules)
をそして、これはあなたが得るものです::
lhs rhs support confidence lift count
[1] {} => {typeZ} 0.50 0.50 1.0000000 2
[2] {} => {typeX} 0.75 0.75 1.0000000 3
[3] {typeW} => {typeX} 0.25 1.00 1.3333333 1
[4] {typeG} => {typeX} 0.25 1.00 1.3333333 1
[5] {typeY} => {typeZ} 0.25 1.00 2.0000000 1
[6] {typeZ} => {typeY} 0.25 0.50 2.0000000 1
[7] {typeY} => {typeX} 0.25 1.00 1.3333333 1
[8] {typeZ} => {typeX} 0.25 0.50 0.6666667 1
[9] {typeY,typeZ} => {typeX} 0.25 1.00 1.3333333 1
[10] {typeX,typeY} => {typeZ} 0.25 1.00 2.0000000 1
[11] {typeX,typeZ} => {typeY} 0.25 1.00 4.0000000 1
外観arules](https://cran.r-project.org/web/packages/arules/index.ht ml) – mtoto