0

I have below data frame where I want to separate my rule column into separate columns.

Data :

          rules    support  confidence  lift count
5   {32,39,6} => {65}   0.00055 1.00    22.3    12
6   {39,6,65} => {32}   0.00055 0.86    23.4    12
9   {14,16,26} => {4}   0.00051 0.79    8.9     11
13  {16,20,4} => {26}   0.00069 0.71    8.0     15
16  {16,26,33} => {4}   0.00055 0.67    7.6     12
1   {53} => {31}        0.00087 0.66    89.6    19

Expected output :

lhs          rhs 
{32,39,6}   {65}
{39,6,65}   {32}
{14,16,26}  {4}

I have tried the below code

rules = sapply(assoc_rules$rules,function(x){
    x = gsub("[\\{\\}]", "", regmatches(x, gregexpr("\\{.*\\}", x))[[1]])
    x = gsub("=>",",",x)
    x = str_replace_all(x," ","")
    return( x )
})
pylearner
  • 1,358
  • 2
  • 10
  • 26

0 Answers0