I have a data frame like the below table. It is a time series by the user.
User | Date | Age | SentimentScore |
---|---|---|---|
a | 9.19 | 20 | 1 |
a | 11.20 | 20 | 2 |
a | 12.10 | 20 | 3 |
b | 9.30 | 19 | 1 |
b | 10.1 | 19 | 4 |
c | 12.1 | 21 | 5 |
I hope to generate a table like this one. Trail 1 means the Mean Sentiment score before a certain date(eg. Nov 7th). Trail 2 means the Mean Sentiment score after a certain date(eg. Nov 7th).
User Age trial Mean Sentiment Score
a 20 1 1-->(mean SentimentScore before 11.7)
a 20 2 2.5 -->(mean SentimentScoree after 11.7)
b 19 1 2.5--->(mean SentimentScoree before 11.7)
c 21 1 NA --->(mean SentimentScoree before 11.7)