Re: [R] sample nth day data in each month

2007-11-19 Thread Gabor Grothendieck
Suggest you read the article in R News 4/1 on dates and times and try this: library(zoo) library(chron) z <- zoo(101:200, seq(chron("1/1/2000"), length = 100)) zz <- z[with(month.day.year(time(z)), day >= 21 & month %% 2 == 1)] zz[!duplicated(as.yearmon(time(zz)))] On Nov 19, 2007 9:57 PM, Ca

Re: [R] sample nth day data in each month

2007-11-19 Thread Carles Fan
many thanks Gabor. Q1: if i want to do with the following 2 conditions, how can i do? condition 1) every n-th day condition 2) every x-month <-x = 1 to 12 Eg: condition 1) every 21-th day condition 2) every 2-month 1st data: 2000-01-21 100 2nd data: 2000-03-21 101 3rd data: 2000-05-21

Re: [R] sample nth day data in each month

2007-11-15 Thread Emmanuel Charpentier
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-Ja

Re: [R] sample nth day data in each month

2007-11-15 Thread Gabor Grothendieck
On Nov 15, 2007 12:54 PM, Carles Fan <[EMAIL PROTECTED]> wrote: > 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 samp

[R] sample nth day data in each month

2007-11-15 Thread Carles Fan
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 ..