Hello, Here are three vectors to give context to my question below:
*id <- c(1,1,1,1,1,2,2,2,3,3,3)) month <- c(1, 1, 2, 3, 6, 2, 3, 6, 1, 3, 5) value <- c(10, 12, 11, 14, 16, 12, 10, 8, 14, 11, 15)* and I want to plot "value" over "month" separately for each "id". Before I can do that, I need to section both month and value, based on ID. I create a my.plot function like this (at this point, it doesn't draw any plots, it is just an effort to help my understand what I'm doing): *my.plot <- function(y) { print(y); print(month[id==y]) }* Now, I tried: *by(value, id, my.plot)* But of course, it didn't do what I wanted. I realized that the parameter passed to my.plot, is a "secion of value" per ID, and not the ID value itself. Question is, how can I get the value of factor ID at each level of by()? Please advise, Merik [[alternative HTML version deleted]] ______________________________________________ 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.