On Aug 29, 2011, at 2:40 PM, Andra Isan wrote:
Hello All,
I have a data frame consisting of 4 columns (id1, id2, y, pred)
where pred is the predicted value based on the glm function and my
data frame is called "all". "data" is another data frame that has
all data but I want to put together some important columns from my
original data frame (data) into another data frame (all) as follows
and I would like them to be sorted based on the id1 and id2. Here is
what I do:
all_data = cbind(oder(data[,2]), order(data[,3]), data[,1], pred)
all = as.data.frame(all_data)
colnames(all) = c("id1", "id2", "y" , "pred")
when I do the ordering thing, I am not sure why I do not get the
corresponding "y" and "pred" values for that specific row after
ordering. Am I doing something wrong in here?
Your error is in not using 'merge' instead of 'cbind'.
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
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.