I have data that looks something like this
df = data.frame(name=c("A","A","B","B"),
group=c("g1","g2","g1","g2"),
V1=c(10,40,20,30),
V2=c(6,3,1,7))
I want to reshape it to look like this:
df = data.frame(name=c("A", "B"),
V1.g1=c(10,20),
V1.g2=c(40,30),
V2.g1=c(6,1),
V2.g2=c(3,7))
Is it possible to do it with tidyR?
I can do it with reshape
reshape(df, idvar='name', timevar='group', direction='wide')
but is always good to learn something new.