Exercise 1
Wide-to-Long:
Using the reshape() parameter “direction=“, “varying=” columns are stacked according to the new records created by the “idvar=” column.

Therefore, convert “data1” to long format, by stacking columns 2 through 4. The new row names are from column “id“. The new time variable is called, “TIME“. The column name of the stacked data is called “Sample“. Set a new dataframe variable called, “data2“.

Exercise 2
Long-to-Wide:
Use direction="wide" to convert “data2” back to the shape of “data1“. Setting a new variable isn’t needed. (Note that rownames from “data2” are retained.)

Exercise 3
Time Variables:
Script a reshape() operation, where “timevar=” is set to the variable within “data2” that differentiates multiple records.

Exercise 4
New Row Names:
Script a reshape() operation, where “data2” is converted to “wide” format, and “new.row.names=” is set to unique “data2$id” names.

Exercise 5
Convert “data2” to wide format. Set “v.names=” to the “data2” column with observations.