I have a following dummy data frame:
group <- c(rep("cat", 3),rep("dog", 3))
time <- c(rep(1:3,2))
mean <- c(78, 81, 83, 76, 83, 85)
df1 <- data.frame(group, time, mean)
And I would like to convert it to the following:
cat <- c(78, 81, 83)
dog <- c(76, 83, 85)
time <- c(1:3)
df2 <- data.frame(cat, dog, time)
I can do it in following way:
df2 <- df1%>% spread(group, mean)
How can I achieve this without using spread from tidyr?