d1 = structure(list(ID = c(118L, 115L, 194L, 7L, 747L)), .Names = "ID", row.names = c(NA,
-5L), class = "data.frame")
demo.ph2 = structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L,
7L, 7L, 20L, 20L, 20L, 20L, 20L, 100L, 100L, 100L, 100L, 115L,
115L, 115L, 115L, 118L, 118L, 118L, 118L, 194L, 194L, 194L, 194L,
747L, 747L, 747L, 747L, 1683L, 1683L, 1683L), AST = c(26, 20,
25, 23, 26, 19, 19, 21, 31, 28, 21, 21, 21, 29, 28, 18, 21, 215.4,
12, 18, 92.4, 383.4, 40.2, 28.8, 36.6, 847, 30, 24, 31, 780,
20.4, 18.6, 18.6, 64, 21, 20, 20, 35, 33, 39), ALB = c(40.99999905,
39.00000095, 39.00000095, 37.99999952, 40, 39.00000095, 35.99999905,
35, 35.99999905, 39.00000095, 40.99999905, 37.00000048, 40.99999905,
40.99999905, 40.99999905, 41.99999809, 43.00000191, 37.6, 34.9,
42.2, 41.7, 23, 21, 32, 32, 27.3, 25.9, 34.1, 29.2, 24, 31, 32,
33, 27, 37, 40, 39, 41.99999809, 39.00000095, 40), SEX = c(1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), RACE = c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L)), .Names = c("ID", "AST", "ALB", "SEX", "RACE"), row.names = c("1",
"19", "54", "75", "95", "103", "620", "638", "673", "694", "713",
"721", "1958", "1976", "2011", "2056", "2064", "8462", "8510",
"8551", "8569", "9867", "9909", "9964", "9978", "9997", "10026",
"10057", "10070", "14118", "14160", "14207", "14221", "18608",
"18635", "18673", "18681", "35762", "35780", "35804"), class = "data.frame")
demo <- merge(x=d1, y=demo.ph2, by="ID", all.x=T)
Why is the order of data record of each ID in demo different from the order of data record of each ID in demo.ph2, for example, when we look at order of AST in ID=7? how to make them (for example, AST) in the same order as in demo.ph2? Thanks |