I have a wide dataset that looks like this:
dataset <- data.frame(id = c(1, 2, 3, 4, 5),
basketball.time1 = c(2, 5, 4, 3, 3),
basketball.time2 = c(3, 4, 5, 3, 2),
basketball.time3 = c(1, 8, 4, 3, 1),
volleyball.time1 = c(2, 3, 4, 0, 1),
volleyball.time2 = c(3, 4, 3, 1, 3),
volleyball.time3 = c(1, 8, 12, 2, 3))
What I want is the dataset in long format, with id
, time
, basketball
, and volleyball
as separate variables. I want to create the time
column with three factors (time1, time2, and time3) using the string that is separated by "." at the end of the basketball and volleyball columns.
Thanks so much!
EDIT: fixed typo