library(readr)
data1<-read_csv(".../file1")
data2<-read_csv(".../file2")
table2<-table(data1$`_SEGMENT_`,data2$`_SEGMENT_`,data1$Subscribed)
This is the frequency table2
I created with three variables, data1 segment as row, data2 segment as column and third dimension 'Subscribed' with 'yes'
and 'no'
.
> table2
, , = no
1 2 3 4 5
1 29 674 5189 7207 88
2 3 194 1393 2166 39
3 18 471 2667 5719 77
4 0 1 2 11 0
5 18 420 2798 4715 88
, , = yes
1 2 3 4 5
1 0 33 262 1000 1
2 0 10 65 322 0
3 0 25 190 1206 2
4 0 0 1 3 0
5 0 26 166 943 3
How to create a lift value table of 'yes' based on table2?
5x5 table and each position value = value of 'yes'
/(value of 'yes'
+value of 'no'
)
e.g. table_liftvalue[1,2] = 33/(33+674)
> table_liftvalue
1 2 3 4 5
1 . 33/(674+33)
2 .
3 .
4 .
5 .
I appreciate any help. [1]: https://i.stack.imgur.com/1w6mj.png
Using
apply
for thesum
, then just divide.Data: