I have a list in long format as follows:
name days N
A 1 80
A 2 90
B 1 70
B 3 85
B 5 100
C 2 80
C 5 95
I would like to obtain the following output:
days 1 2 3 4 5
A 80 90 NA NA NA
B 70 NA 85 NA 100
C NA 80 NA NA 95
I tried the function reshape and obtained the error:
reshape(data, idvar = data[,1], timevar = [,3], direction = "wide")
Error in `[.data.frame`(data, , timevar) : undefined columns selected
`