From this I wish to generate a "wide" data frame (note: repetitions at
identical "Dose" are given indepently for each "ID"):
ID Dose Var001.Response Var002.Response
ID001 100 90% 100%
ID001 100 15% 100%
ID001 100 NA 90%
ID001 80 90% 100%
ID001 80 90% NA
ID001 50 90% 100%
ID001 25 NA 70%
ID002 100 90% 100%
ID002 100 15% NA
ID002 80 90% 100%
ID002 50 90% 100%
I tried
reshape(DF, timevar="Var", idvar=c("ID", "Dose"), direction="wide")
and obtained:
ID Dose Response.Var001 Response.Var002
1 ID001 100 90% 100%
3 ID001 80 90% 100%
5 ID001 50 90% 100%
11 ID001 25 <NA> 70%
12 ID002 100 90% 100%
14 ID002 80 90% 100%
15 ID002 50 90% 100%
This table is close to what I need, but it lacks entries if more than one
"Response" exists for a given "Dose".
Where is my mistake?
Best wishes
Christian