Carles Fan a écrit :
> Dear all
> 
> i have a time series containing trading dates and historical stock prices:
> Date             Price
> 10-Jan-2007  100
> 11-Jan-2007  101
> 13-Jan-2007  99
> ......
> ......
> ......
> 10-Nov-2007  200
> 
> i want to sample every 21st data of each month:
> 21-Jan-2007 101
> 21-Feb-2007 111
> 21-Mar-2007 131
> ......
> ......
> ......
> 21-Oct-2007 140
> 
> 1) how can i do that?

YourDataFrame[strptime(YourDataFrame$Date,"%Y-%b-%d")$mday==21,]
# beware your locale !

> 2) if some of the dates are non-trading day, how can i tell "R" to use
> "modified following" or "following" data?


Dunno : what is a"non-trading day" ?

HTH

                                        Emmanuel Charpentier

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to