My dataset is organized as shown below (just a small extract) : for a given subject (here, subject=5), I have 3 tests performed at times D-1, D1-8h and D2-24h:
    SUBJECT   TIME                    TEST RESULT UNITS              RANGES
591       5    D-1    Leukoyte count urine      1   /?L            |-< 15|-
592       5    D-1 Erythrocyte count urine      0   /?L            |-< 19|-
593       5    D-1  Glucose dipstick urine Normal  None |+ from 50 mg/dL-|-
684       5  D1 8h    Leukoyte count urine      0   /?L            |-< 15|-
687       5  D1 8h Erythrocyte count urine      0   /?L            |-< 19|-
683       5  D1 8h  Glucose dipstick urine Normal  None |+ from 50 mg/dL-|-
694       5 D2 24h    Leukoyte count urine      1   /?L            |-< 15|-
695       5 D2 24h Erythrocyte count urine      0   /?L            |-< 19|-
696       5 D2 24h  Glucose dipstick urine Normal  None |+ from 50 mg/dL-|-
I would like to reorganize these data in a table set by columns, in the following form:
TEST D-1 D1-8h D2-24h UNITS RANGES
so that I get one line by test.
I am confused with "table" and "aggregate", and I don't find a proper way to do that, although I am sure it's not so complicated...
Could you gve me some help?
Thanks
Here is dput:
> dput(dataset)
structure(list(SUBJECT = c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L
), TIME = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), .Label = c("D-1", 
"D1 8h", "D2 24h", "D4 72h"), class = "factor"), TEST = structure(c(35L, 
24L, 28L, 35L, 24L, 28L, 35L, 24L, 28L), .Label = c("", "Alkaline phosphatase", 
"APTT", "Basophils", "Basophils (%)", "Calcium", "CD19", "CD19 abs.", 
"CD3", "CD3 abs.", "CD4/CD8 ratio", "CD4+", "CD4+ abs.", "CD56", 
"CD56 absolute", "CD8+", "CD8+ abs.", "Chloride", "CK (creatine kinase)", 
"Creatinine", "Direct bilirubin (conjug)", "Eosinophils", "Eosinophils (%)", 
"Erythrocyte count urine", "Erythrocyte dipstick urine", "Gamma GT", 
"Glucose", "Glucose dipstick urine", "GOT (AST)", "GPT (ALT)", 
"Hematocrit", "Hemoglobin", "Ketone bodies urine", "Leukocyte esterase urine", 
"Leukoyte count urine", "Lymphocytes", "Lymphocytes (%)", "Monocytes", 
"Monocytes (%)", "Neutrophils", "Neutrophils (%)", "pH urine", 
"Platelet count", "Potassium", "Protein urine", "PT INR", "Red blood cell count", 
"Reticulocytes", "Reticulocytes %", "Serum  Albumine", "Sodium", 
"Total bilirubin", "Total cholesterol", "Total protein", "Triglycerides", 
"Urea", "Urine glucose quantitative", "Urine protein quantitative", 
"White blood cell count"), class = "factor"), RESULT = c("1", 
"0", "Normal", "0", "0", "Normal", "1", "0", "Normal"), UNITS = c("/?L", 
"/?L", "None", "/?L", "/?L", "None", "/?L", "/?L", "None"), RANGES = c("|-< 15|-", 
"|-< 19|-", "|+ from 50 mg/dL-|-", "|-< 15|-", "|-< 19|-", "|+ from 50 mg/dL-|-", 
"|-< 15|-", "|-< 19|-", "|+ from 50 mg/dL-|-")), .Names = c("SUBJECT", 
"TIME", "TEST", "RESULT", "UNITS", "RANGES"), row.names = c(591L, 
592L, 593L, 684L, 687L, 683L, 694L, 695L, 696L), class = "data.frame")
 
     
    