Displaying 2 results from an estimated 2 matches for "prevfriday".
2004 Mar 01
6
Find out the day of week for a chron object?
I know that this is correct:
library(chron)
x = dates("01-03-04", format="d-m-y", out.format="day mon year")
print(x)
It gives me the string "01 Mar 2004" which is correct.
I also know that I can say:
print(day.of.week(3,1,2004))
in which case he says 1, for today is monday.
My question is: How do I combine these two!? :-) I have a
2004 Mar 29
9
Aggregating frequency of irregular time series
...P as of this friday.
i = i+7; # Get ready for the next time --
}
return(100*diff(log(f.ltp), 1)); # Pretty computation of returns vector! :-)
}
### ---------------------------------------------------------------------------
# Compute the friday before the stated date.
prevFriday <- function(x) {
repeat {
x <- x - 1;
if (5 == with(month.day.year(x), day.of.week(month,day,year))) break;
}
return(x);
}
# Other tricks which could have worked also :
# do.call( "day.of.week", month.day.year(x) )
# as.numeric(x-3)%%7 # uses fact that chron(3) is...