Re: [R] use subset to trim data but include last per category

2012-09-09 Thread Giovanni Azua
Hello, This solves my problem in a horribly inelegant way that works: df <- data.frame(n=newInput$n, iter=newInput$iter, Error=newInput$Error, Duality_Gap=newInput$Duality, Runtime=newInput$Acc) df_last <- aggregate(x=df$iter, by=list(df$n), FUN=max) names(df_last)[names(df_last)=="Group.1"] <-

Re: [R] use subset to trim data but include last per category

2012-09-09 Thread William Dunlap
)) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Giovanni Azua > Sent: Sunday, September 09, 2012 8:14 AM > To: r-help@r-project.org > Subject: [

Re: [R] use subset to trim data but include last per category

2012-09-09 Thread Giovanni Azua
Hi Jeff, Thanks for your help, but this doesn't work, there are two problems. First and most important I need to keep the last _per category_ where my category is n and not the last globally. Second, there seems to be an issue with the subset variation that ends up not filtering anything ... bu

Re: [R] use subset to trim data but include last per category

2012-09-09 Thread Jeff Newmiller
dfthin <- df[ c(which(iter %% 500 == 0),nrow(df) ] or dfthin <- subset(df, (iter %% 500 == 0) | (seq.int(nrow(df)==nrow(df))) N.B. You should avoid using the name "df" for your variables, because it is the name of a built-in function that you are hiding by doing so. Others may be confused, an

[R] use subset to trim data but include last per category

2012-09-09 Thread Giovanni Azua
Hello, I bumped into the following funny use-case. I have too much data for a given plot. I have the following data frame df: > str(df) 'data.frame': 5015 obs. of 5 variables: $ n : Factor w/ 5 levels "1000","2000",..: 1 1 1 1 1 1 1 1 1 1 ... $ iter : int 10 20 30 40 50 60