My data looks like this:
Smoker PtNo Day Hour FEV1 timename
1 0 1 1 0 3.26 d1h0
2 0 1 1 2 3.05 d1h2
3 0 1 1 4
Are you looking for this?
reshape(dat,direction='wide',
idvar=c('Smoker','PtNo'),
v.names='FEV1',
timevar='timename',
drop=c('Day','Hour'))
Smoker PtNo FEV1.d1h0 FEV1.d1h2 FEV1.d1h4 FEV1.d1h6 FEV1.d2h0 FEV1.d2h2 FEV1.d2h4 FEV1.d2h6 FEV1.d3h0 FEV1.d3h2
1 0 1 3.26 3.05 3.02 3.27 3.28 3.07 3.35 3.07 3.28 3.44