Suppose I have this data frame:
name <- rep(LETTERS[seq(from=1, to =2)], each=3)
MeasA <- c(1:6)
MeasB <- c(7:12)
df <- data.frame(name, MeasA, MeasB)
And I want to reshape into a format which has no idvar like this:
MeasA_A MeasB_A MeasB_B MeasB_B
1 7 4 10
2 8 5 11
3 9 6 12
I have been reading about reshape and melt:
Reshaping data frame with duplicates
http://seananderson.ca/2013/10/19/reshape.html
But with those functions I need to specify an idvar. Ive tried:
tt <- reshape(df, timevar = "name", direction="wide")
and
tt <- dcast(df, ~name)
But they clearly dont work. Perhaps I need to use split (Split data.frame based on levels of a factor into new data.frames) then a reshape?