I assume this has been asked multiple times but I couldn\'t find the proper words to find a workable solution.
How can I spread() a data frame based on
spread()
Your entry data frame is not tidy. You should use gather to make it so.
gather(df, key, value, -id, -time) %>% mutate(key = paste0(key, "time", time)) %>% select(-time) %>% spread(key, value)