s
Cc: R help ; ramoss
Sent: Saturday, October 20, 2012 12:04 PM
Subject: RE: [R] Creating a new by variable in a dataframe
> d$flag<-unlist(rbind(lapply(split(d,d$date),function(x) x[3]==max(x[3]
I think that line is unnecessarily complicated. lapply() returns a list
and rbind applied
result do you want when there are several transactions at the last time
in the day?
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 arun
> Sent: Friday
R help; Flavio Barros; ramoss
> Subject: Re: [R] Creating a new by variable in a dataframe
>
> HI Bill,
>
> Thanks for the reply.
> It was unnecessarily complicated.
> d$flag<-unlist(lapply(split(d,d$date),function(x)
> x[3]==max(x[3])),use.names=FALSE)
> #or
> d$f
ftware
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of arun
> Sent: Friday, October 19, 2012 7:49 PM
> To: Flavio Barros
> Cc: R help; ramoss
> Subject: Re: [R] Creating a new by
T10 2012-10-23 17:00:00 TRUE
str(d1)
#'data.frame': 10 obs. of 3 variables:
# $ transaction: chr "T01" "T02" "T03" "T04" ...
# $ datetime : POSIXct, format: "2012-10-19 08:00:00" "2012-10-19 09:00:00"
...
# $ flag
#12 9/10/2012 9 66 Y
#13 9/20/2012 12 84 Y
A.K.
- Original Message -
From: ramoss
To: r-help@r-project.org
Cc:
Sent: Friday, October 19, 2012 1:51 PM
Subject: [R] Creating a new by variable in a dataframe
Hello,
I have a datafram
4 28 28
#11 2012-09-10 5 51 NA
#12 2012-09-10 9 66 66
#13 2012-09-20 12 84 84
- Original Message -
From: ramoss
To: r-help@r-project.org
Cc:
Sent: Friday, October 19, 2012 1:51 PM
Subject: [R] Creat
T01 2012-10-19 08:00 FALSE FALSE
> 2 T02 2012-10-19 09:00 FALSE FALSE
> 3 T03 2012-10-19 10:00 FALSE FALSE
> 4 T04 2012-10-19 11:00TRUETRUE
> 5 T05 201
Thanks for all the help guys.
This worked for me:
all6 <- arrange(all6, tdate,event_tim)
lt <- ddply(all6,.(tdate),tail,1)
lt$last_trans <-'Y'
all6 <-merge(all6,lt, by.x=c("tdate","event_tim"),
by.y=c("tdate","event_tim"),all.x=TRUE)
--
View this message in context:
http://r.789695.n4.nabbl
0-23 17:00 TRUE TRUE
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 ramoss
> Sent: Friday, October 19, 2012 10:52 AM
> To: r-
Hello,
I have a dataframe w/ 3 variables of interest: transaction,date(tdate) &
time(event_tim).
How could I create a 4th variable (last_trans) that would flag the last
transaction of the day for each day?
In SAS I use:
proc sort data=all6;
by tdate event_tim;
run;
/*Create last transacti
11 matches
Mail list logo