Skip to content
Prev 1732 / 15274 Next

Problem with the timeDate function

From: Strong <strongthinking at gmail.com>
Subject: Re: [R-SIG-Finance] Problem with the timeDate function
Date: Tue, 25 Sep 2007 01:06:35 +0900 (JST)

Dear all

I have already found a way to do it myself.

Suppose we have a character vector date like the following:

"2006.01" "2006.02" "2006.03" "2006.04" "2006.05" "2006.06"

First, use the function gsub to replace the "." with "-". 

date <- gsub("/", "-", date)

And then, use the function paste to add a date to it, say "01".

paste(date, "-01", sep="")

Finally, you can convert it to timeDate object by using function timeDate without any error message!

date.td <- timeDate(date, format="%Y-%m-%d")



Regards

Strong Chen