This may be similar to the pivot function but I'm not sure if it applies in this case:
If I have a df:
date x1 x2
1 1-01 a b
2 1-01 c d
3 1-02 e f
4 1-02 g h
5 1-03 i j
Can I combine the x1 and x2 column into this:
date combined type
1 1-01 a x1
2 1-01 b x2
3 1-01 c x1
4 1-01 d x2
5 1-02 e x1
6 1-02 f x2
7 1-02 g x1
8 1-02 h x2
9 1-03 i x1
10 1-03 j x2
I tried using paste (e.g. df <- paste(df$x1,df$x2)) but I lose out on the labels. I'm not sure if I can incorporate the pivot_longer function into a mutate statement in my ggplot statement.
tidyr::pivot_longer(quux, -date, names_to="type", values_to="combined")andreshape2::melt(quux, id.vars="date", variable.name="type", value.name="combined")