Thank you again all responders. Dan your solution was both easy & miraculous.
--
View this message in context:
http://r.789695.n4.nabble.com/Can-you-have-a-by-variable-in-Lag-function-as-in-SAS-tp4649647p4649773.html
Sent from the R help mailing list archive at Nabble.com.
Hi Ramoss,
There are a few solutions to this - probably the best solution involves proper
handling of time series/date objects.
But, for "an" answer try:
# Build a data frame ...
set.seed(123)
someTimes <- sapply(1:5, function(i) sort(round(runif(6, 0, 24
myDf <- data.frame(Day = rep(1:5, ea
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of ramoss
> Sent: Thursday, November 15, 2012 11:56 AM
> To: r-help@r-project.org
> Subject: [R] Can you have a by variable in Lag function as in SAS
>
> H
Hello,
I want to use lag on a time variable but I have to take date into
consideration ie I don't want days to overlap ie:
I don't want my first time of today to match my last time of yeterday.
In SAS I would use :
data x;
set y;
by date tim;
previous=lag(tim);
if first.date then
d
4 matches
Mail list logo