Possibly a fairly simple question, however I have not been able to solve it so far. My goal is to redesign a data frame in R that has the following format: