[R] Calculating the trading days

Ravi S. Shankar ravis at ambaresearch.com
Fri Jul 17 07:22:18 CEST 2009


Hi R,

I have two columns of date in a CSV file in the below format
29-Dec-06	25-Jan-07
29-Dec-06	25-Jan-07
29-Dec-06	25-Jan-07
2-Jan-07	25-Jan-07
2-Jan-07	25-Jan-07
2-Jan-07	25-Jan-07

I read in R using   dat<-read.csv("Z:\\data.csv"). 
> class(dat[,1])
[1] "factor"

So I use
dat[,1]=as.Date(as.character(dat[,1]),"%d-%b-%YY")
> class(dat[,1])
[1] "Date"
 But when I do 
> fix(dat)
Warning: class discarded from column 'Date'
Also 
> dat[1,1]
[1] NA

My task is to compute the number of trading days between the two dates
in col A and Col B. Any help would be appreciated!

Thank you,
Ravi Shankar S 
This e-mail may contain confidential and/or privileged i...{{dropped:10}}




More information about the R-help mailing list