# How to find transictions and group variables

Having a dataset like this:

structure(list(id = c(1L, 1L, 1L, 1L, 2L, 2L, 2L), stock = c("stockA",
"stockB", "stockC", "stockD", "stockA", "stockB", "stockD"),
var1_before = c(-0.3957, -0.0201, -0.3957, -0.3729, 0.0498000000000001,
-0.5075, -0.3242), var2_before = c(-1.3106, -1.4492, -1.3106,
-1.6134, -1.3222, -1.5452, -1.3168), var3_before = c(3.3374,
2.6408, 3.3374, 3.4728, -0.2173, 3.6311, 3.0884), var4_before = c(-1533,
-1.3378, -1533, -1.5256, -1.6596, -1.7272, -1.4142), var5_before = c(0.3841,
0.1647, 0.3841, 551, 3.5372, 0.3317, 0.4339), var1_after = c(-0.4975,
-0.4107, -0.3557, -0.5223, -0.2173, -0.2003, -0.4473), var2_after = c(-1.6707,
-1.5982, -1.4963, -1.6512, -1.6596, -1.7075, -1.6361), var3_after = c(3.9367,
3.7744, 3398, 3.9537, 3.5372, 3.4673, 3.7018), var4_after = c(-1.6377,
-1.5513, -1.6543, -1.6823, -1.5497, -1.3507, -1.8195), var5_after = c(0.6483,
0.5484, 0.4024, 0.3634, 0.4352, 0.3594, 0.3441)), class = "data.frame", row.names = c(NA,
-7L))


the variables are id: is a user stock: the name of a stock that a user (id) has an impression/sentiment for this. For every user the stock is unique var1_before-var5_before and var1_before-var1_after: are variables which are score of sentiments. For example var1_before is the sentiment the user has before a specific event and var1_after is the sentiment score the user has after a specific event. the same for 2,3,4,5.

I know that there are some user which can before and after event and moved from var1_before to var3_after.

For every stock how is it possible to find how most of users were in before label, for example for stockA var1_before and var4_before affect most but for stockB var2_before seems to exist most.

Is there any machine learning approach which could make it?