lou
To: arun
Cc: R help
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 wrote:
> HI Steve,
>
> Thanks for testing.
>
> When I run a slightly bigger dataset:
> set.seed(1254)
> name
Hi,
On Thu, Aug 15, 2013 at 4:03 PM, arun 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)
> library
lt;- as.data.frame(res)
system.time(res1<-dat2[c(diff(as.numeric(as.factor(dat2$Date))),1)>0,])
row.names(resNew)<- row.names(res1)
attr(resNew,"row.names")<- attr(res1,"row.names")
identical(resNew,res1)
#[1] TRUE
A.K.
----- Original Message -
From: Steve
]
names(res1)<-names(res3New)
identical(res1,as.data.frame(res3New))
#[1] TRUE
A.K.
- Original Message -
From: Steve Lianoglou
To: arun
Cc: R help
Sent: Thursday, August 15, 2013 4:48 PM
Subject: Re: [R] How to extract last value in each group
Hi,
On Thu, Aug 15, 2013 at 1:38 PM, a
Hi,
On Thu, Aug 15, 2013 at 1:38 PM, arun 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 tried:
> syste
5, 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 to see the
time you reported for the data.table option:
> #separate the data.table creation step:
>
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],
dat2, key=c('Date', 'Time'))
system.time(ans <- dt1[, .SD[.N], by='Date'])
# user system elapsed
# 38.500 0.000 38.566
ans1<- as.data.frame(ans)
row.names(ans1)<- row.names(res1)
attr(ans1,"row.names")<- attr(res1,"row.names")
ident
t;>> }
>>>
>>> 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
>
>>
>>> -----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
x == max(x, ]
> >> }
> >> f2 <- function (dataFrame) {
> >> dataFrame[cumsum(with(dataFrame, tapply(Time, list(Date), FUN =
> which.max))), ]
> >> }
> >>
> >> Bill Dunlap
> >> Spotfire, TIBCO Software
>
rame, tapply(Time, list(Date), FUN =
>> which.max))), ]
>> }
>>
>> Bill Dunlap
>> Spotfire, TIBCO Software
>> wdunlap tibco.com
>>
>>
>>> -----Original Message-----
>>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
; 4 06/01/2010 1700 136.55 136.55 136.55 136.55 1 0
>> 11 06/02/2010 338 136.80 136.80 136.80 136.80 3 0
>>
>> #or
>> dat1[as.logical(with(dat1,ave(Time,Date,FUN=function(x) x==max(x,]
>> #Date Time O H L C U D
>> #4 06/01/2010 1700 136.5
ware
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
10 338 136.80 136.80 136.80 136.80 3 0
> A.K.
>
>
>
>
> ----- Original Message -----
> From: Noah Silverman
> To: "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
ent: 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 is
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 actuall
17 matches
Mail list logo