Geoffrey:
There may be something for this in one of the packages dealing with dates.
If not, here's one (incomplete) idea, based on something I used for a similar
issue a little while ago. Essentially, make a data frame that ranks each
weekday over a period in ascending order. This data frame
Thank you for the email. The data is unbalanced, meaning that some days are
missing. So the sequence of days could be something like Tuesday,
Wednesday, Friday, Monday. The diff function would produce 1, 2, 3. But I
would like it to produce 1, 2, 1 since there is really only 1 day between
Frida
Your request seems bizarre to me. If you really want to ignore the actual time
intervals, just do your analysis without the actual dates.
If you just want forward-looking time intervals, then put them in the correct
index locations.
?diff
c(diff(DF$DATE),1)
Geoff,
I think you could write an if loop to solve this.
You could write:
for(i in 1:num_obs){
if(DAYS[i]=='Monday'){
DF$DAYS.BETWEEN[i]<-1
}
}
Where 'num_obs' is the total number of temperature observations you have.
This would only be correct if you had no missing data on Fridays. Also, if
Hello, I have some unbalanced panel data that is measured on weekdays only
(i.e., excluding Saturday and Sunday). I would like to get the number of
days between dates such that the number of days between a Friday and a
Monday is 1 (and not 3). Here is some code to illustrate my problem:
library(
5 matches
Mail list logo