Re: [R] Accessing the index of factor in by() function

2011-08-01 Thread Merik Nanish
g a value, whatever. I want to do it efficiently though (for loops are very slow). How can I do that? M On Tue, Jul 26, 2011 at 10:12 AM, Ista Zahn wrote: > Hi Merik, > Please keep the mailing list copied. > > On Tue, Jul 26, 2011 at 6:44 AM, Merik Nanish > wrote: > > You can c

Re: [R] Accessing the index of factor in by() function

2011-07-27 Thread Merik Nanish
On Tue, Jul 26, 2011 at 10:12 AM, Ista Zahn wrote: > OK, easy enough: > > dat.tmp <- data.frame(id, month, value) > my.plot <- function(dat) {print(dat[, c("id", "value")])} > by(dat.tmp, id, my.plot) Excellent. The output of that last line is: * id value 1 110 2 112 3 111 4 1

[R] Accessing the index of factor in by() function

2011-07-25 Thread Merik Nanish
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 nee

[R] Function to save plots

2011-06-01 Thread Merik Nanish
Hello, I'm using ROCR to plot ROC Curves and I want to automate the saving of plots into PNG files using a custom function. My data frames are named like test1, test2, test3. Each data frame has three variables: method1, method2, goldstandard. Right now, for each plot I have to run: png('test1_