How to make such transformation as in the below image ?
Advertisement
Answer
You can use the gather function form the tidyr package:
x
library(tidyr)
client1 <- c(23, 12, NA)
client2 <- c(45, 34, 56)
df1 <- data.frame(client1, client2)
df2 <- gather(df1, key = "Clients", value = "Money", na.rm = TRUE)