I have a dataframe like below.
user cat val
u1 cat1 1
u1 cat2 2
u1 cat3 3
u2 cat1 5
u3 cat4 4
And wish to transform it like this.
user cat val(avg)
u1 cat1 1
u1 cat2 2
u1 cat3 3
u1 cat4 4
u2 cat1 5
u2 cat2 2
u2 cat3 3
u2 cat4 4
u3 cat1 3
u3 cat2 2
u3 cat3 3
u3 cat4 4
There are also a couple of numeric columns to the right of cat, which hopefully can be filled with either NA; or if possible averaged out.