Re: [R] How to extract last value in each group

2013-08-15 Thread peter dalgaard
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group Hi, Try: dat1- read.table(text= Date Time O H L

Re: [R] How to extract last value in each group

2013-08-15 Thread arun
help r-help@r-project.org Sent: Wednesday, August 14, 2013 5:22 PM Subject: Re: [R] How to extract last value in each group Or with plyr: R library(plyr) R ans - ddply(x, .(Date), function(df) df[which.max(df$Time),]) -steve On Wed, Aug 14, 2013 at 2:18 PM, Steve Lianoglou lianoglou.st

Re: [R] How to extract last value in each group

2013-08-15 Thread Steve Lianoglou
Hi, Looks like you have some free time on your hands :-) Something looks a bit off here, though, I was surprised to see the time you reported for the data.table option: #separate the data.table creation step: dt1 - data.table(dat2, key=c('Date', 'Time')) system.time(ans - dt1[, .SD[.N],

Re: [R] How to extract last value in each group

2013-08-15 Thread arun
...@gmail.com; David Winsemius dwinsem...@comcast.net; R help r-help@r-project.org Sent: Thursday, August 15, 2013 3:52 PM Subject: Re: [R] How to extract last value in each group Hi, Looks like you have some free time on your hands :-) Something looks a bit off here, though, I was surprised

Re: [R] How to extract last value in each group

2013-08-15 Thread Steve Lianoglou
Hi, On Thu, Aug 15, 2013 at 1:38 PM, arun smartpink...@yahoo.com wrote: I tried it again on a fresh start using the data.table alone: Now. dt1 - data.table(dat2, key=c('Date', 'Time')) system.time(ans - dt1[, .SD[.N], by='Date']) # user system elapsed # 40.908 0.000 40.981 #Then

Re: [R] How to extract last value in each group

2013-08-15 Thread arun
)  identical(res1,as.data.frame(res3New)) #[1] TRUE A.K. - Original Message - From: Steve Lianoglou lianoglou.st...@gene.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 15, 2013 4:48 PM Subject: Re: [R] How to extract last value in each group Hi

Re: [R] How to extract last value in each group

2013-08-15 Thread arun
,row.names)- attr(res1,row.names)  identical(resNew,res1) #[1] TRUE A.K. - Original Message - From: Steve Lianoglou lianoglou.st...@gene.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 15, 2013 4:48 PM Subject: Re: [R] How to extract last

Re: [R] How to extract last value in each group

2013-08-15 Thread Steve Lianoglou
Hi, On Thu, Aug 15, 2013 at 4:03 PM, arun smartpink...@yahoo.com wrote: HI Steve, Thanks for testing. When I run a slightly bigger dataset: set.seed(1254) name- sample(letters,1e7,replace=TRUE) number- sample(1:10,1e7,replace=TRUE) datTest- data.frame(name,number,stringsAsFactors=FALSE)

Re: [R] How to extract last value in each group

2013-08-15 Thread arun
lianoglou.st...@gene.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 15, 2013 11:28 PM Subject: Re: [R] How to extract last value in each group Hi, On Thu, Aug 15, 2013 at 4:03 PM, arun smartpink...@yahoo.com wrote: HI Steve, Thanks for testing. When I run

[R] How to extract last value in each group

2013-08-14 Thread Noah Silverman
Hello, I have some stock pricing data for one minute intervals. The delivery format is a bit odd. The date column is easily parsed and used as an index for an its object. However, the time column is just an integer (1:1807) I just need to extract the *last* entry for each day. Don't

Re: [R] How to extract last value in each group

2013-08-14 Thread arun
: Sent: Wednesday, August 14, 2013 3:56 PM Subject: [R] How to extract last value in each group Hello, I have some stock pricing data for one minute intervals. The delivery format is a bit odd.  The date column is easily parsed and used as an index for an its object.  However, the time column

Re: [R] How to extract last value in each group

2013-08-14 Thread Noah Silverman
r-help@r-project.org Cc: Sent: Wednesday, August 14, 2013 3:56 PM Subject: [R] How to extract last value in each group Hello, I have some stock pricing data for one minute intervals. The delivery format is a bit odd. The date column is easily parsed and used as an index for an its

Re: [R] How to extract last value in each group

2013-08-14 Thread William Dunlap
tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group Hi, Try: dat1- read.table(text

Re: [R] How to extract last value in each group

2013-08-14 Thread Steve Lianoglou
Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group Hi, Try

Re: [R] How to extract last value in each group

2013-08-14 Thread Steve Lianoglou
-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group Hi, Try: dat1- read.table(text= Date Time O H L C U D 06/01/2010 1358 136.40 136.40

Re: [R] How to extract last value in each group

2013-08-14 Thread Michael Hannon
[mailto: r-help-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group Hi, Try: dat1- read.table(text= Date Time O H L C U D 06/01/2010

Re: [R] How to extract last value in each group

2013-08-14 Thread David Winsemius
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 arun Sent: Wednesday, August 14, 2013 1:08 PM To: Noah Silverman Cc: R help Subject: Re: [R] How to extract last value in each group