I got advice here that I didn't understand! Can I ask to explain me the meaning
of this procedure: first get the structure, and then assign it back. For what?
Thanks! (Great thanks to Moderator/Admin!)
You should learn to post in plain text and use dput to present your data
structures. At your console do this
dput(treat)
# and this will appear. Copy it to your plain-text message:
structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
"start", "stop", "censor", "sex", "age", "stage", "treatment"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
)):
Then we can just do this:
treat <- structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
"start", "stop", "censor", "sex", "age", "stage", "treatment"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
))
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.