Re: [R] Removing rows with earlier dates

2010-12-29 Thread Ali Salekfard
Thanks to everyone. Joshua's response seemed the most concise one, but it used up so much memory that my R just gave error. I checked the other replies and all in all I came up with this, and thought to share it with others and get comments. My structure was as follows: ACCOUNT RULE DATE A1

Re: [R] Removing rows with earlier dates

2010-12-29 Thread Martin Maechler
David Winsemius dwinsem...@comcast.net on Fri, 24 Dec 2010 11:47:05 -0500 writes: On Dec 24, 2010, at 11:04 AM, David Winsemius wrote: On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote: Hi all, I'm new to the list but have benfited from it quite

Re: [R] Removing rows with earlier dates

2010-12-29 Thread David Winsemius
On Dec 29, 2010, at 9:24 AM, Ali Salekfard wrote: Thanks to everyone. Joshua's response seemed the most concise one, but it used up so much memory that my R just gave error. I checked the other replies and all in all I came up with this, and thought to share it with others and get

Re: [R] Removing rows with earlier dates

2010-12-29 Thread David Winsemius
On Dec 29, 2010, at 11:03 AM, Ali Salekfard wrote: David, Thanks alot. Your code is worked fine on the whole dataset (no memory error as I had with the other ideas). I do like the style - especialy the fact that it is all in one line - , but for large datasets it takes longer than

Re: [R] Removing rows with earlier dates

2010-12-29 Thread Ali Salekfard
David, Thanks alot. Your code is worked fine on the whole dataset (no memory error as I had with the other ideas). I do like the style - especialy the fact that it is all in one line - , but for large datasets it takes longer than what I wrote. I ran it on the same machine with the same set of

Re: [R] Removing rows with earlier dates

2010-12-29 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ali Salekfard Sent: Wednesday, December 29, 2010 6:25 AM To: r-help@r-project.org Subject: Re: [R] Removing rows with earlier dates Thanks to everyone. Joshua's response

[R] Removing rows with earlier dates

2010-12-24 Thread Ali Salekfard
Hi all, I'm new to the list but have benfited from it quite extensively. Straight to my rather strange question: I have a data frame that contains mapping rules in this way: ACCOUNT, RULE COLUMNS, Effective Date The dataframe comes from a database that stores all dates. What I would like to

Re: [R] Removing rows with earlier dates

2010-12-24 Thread David Winsemius
On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote: Hi all, I'm new to the list but have benfited from it quite extensively. Straight to my rather strange question: I have a data frame that contains mapping rules in this way: ACCOUNT, RULE COLUMNS, Effective Date The dataframe comes from

Re: [R] Removing rows with earlier dates

2010-12-24 Thread David Winsemius
On Dec 24, 2010, at 11:04 AM, David Winsemius wrote: On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote: Hi all, I'm new to the list but have benfited from it quite extensively. Straight to my rather strange question: I have a data frame that contains mapping rules in this way: ACCOUNT,

Re: [R] Removing rows with earlier dates

2010-12-24 Thread Joshua Wiley
Hi, On Fri, Dec 24, 2010 at 5:45 AM, Ali Salekfard salekf...@googlemail.com wrote: [snip] I have a data frame that contains mapping rules in this way: ACCOUNT, RULE COLUMNS, Effective Date The dataframe comes from a database that stores all dates. What I would like to do is to create a

Re: [R] Removing rows with earlier dates

2010-12-24 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ali Salekfard Sent: Friday, December 24, 2010 5:46 AM To: r-help@r-project.org Subject: [R] Removing rows with earlier dates Hi all, I'm new to the list but have benfited

Re: [R] Removing rows with earlier dates

2010-12-24 Thread Joshua Wiley
with(YourDataFrame, tapply(`Effective Date`, `RULE COLUMNS`,  function(x) x[which.max(x)])) David pointed out that this will just return a table of dates. One work around is: do.call(rbind, by(DataFrame, DataFrame[, RULE COLUMNS], function(x) x[which.max(x[, Effective Date]), ])) but that

Re: [R] Removing rows with earlier dates

2010-12-24 Thread Greg Snow
Whenever a task calls for breaking a data object into pieces, operate on the pieces, then put it back together, then think about using the plyr package. Sent from my iPod On Dec 24, 2010, at 6:58 AM, Ali Salekfard salekf...@googlemail.com wrote: Hi all, I'm new to the list but have