Dear All
I am a beginner of Rmetrics. It is the first time I posts on the mailing list.
I am having a problem with the use of timeDate function.
I tried to use timeDate function in the fCalendar package to convert a character string of date to into the timeDate object.
My script is something like the followings:
< date <- c("1990.01", "1990.02")
< date.td <- timeDate(date, format="%Y.%m")
And then, I got the following error message:
Error in if (sum(lt$sec + lt$min + lt$hour) == 0) isoFormat = "%Y-%m-%d" :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown Format Specification in: .whichFormat(charvec)
I don't know what's wrong with my format specification. It seems the reason is I am not using the standard iso format, although I do believe the flexible specification of time format is allowed by the timeDate function just like in S-Plus.
Can anyone help me?
Thanks in advance.
Strong Chen
phd Student, Graduate School of Commerce and Management;
Hitotusbashi University, Tokyo, Japan
Problem with the timeDate function
4 messages · Moshe Olshansky, Strong
1 day later
Hello,
I am also new to Rmetrics so take what I say with
caution.
The string "1990.01" is not a valid date - you must
add a day also (even if you do not care about the day
add a dummy one, let say 1, so that you date is
"1990.01.01"). This is a valid date but then you have
another problem (as indicated by your error message) -
if you specify date only then the format is assumed to
be "%Y-%m-%d" and so a period (.) can not be a
separator. So you can either specify the date as
"1990-01-01" or supply a valid time as well, i.e.
timeDate("1990.02.01.00.00.01",format="%Y.%m.%d.%H.%M.%S").
Regards,
Moshe.
--- Strong <strongthinking at gmail.com> wrote:
Dear All
I am a beginner of Rmetrics. It is the first time I
posts on the mailing list.
I am having a problem with the use of timeDate
function.
I tried to use timeDate function in the fCalendar
package to convert a character string of date to
into the timeDate object.
My script is something like the followings:
< date <- c("1990.01", "1990.02")
< date.td <- timeDate(date, format="%Y.%m")
And then, I got the following error message:
Error in if (sum(lt$sec + lt$min + lt$hour) == 0)
isoFormat = "%Y-%m-%d" :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown Format Specification in:
.whichFormat(charvec)
I don't know what's wrong with my format
specification. It seems the reason is I am not
using the standard iso format, although I do
believe the flexible specification of time format is
allowed by the timeDate function just like in
S-Plus.
Can anyone help me?
Thanks in advance.
Strong Chen
phd Student, Graduate School of Commerce and
Management;
Hitotusbashi University, Tokyo, Japan
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
From: Moshe Olshansky <m_olshansky at yahoo.com> Subject: Re: [R-SIG-Finance] Problem with the timeDate function Date: Sun, 23 Sep 2007 17:14:04 -0700 (PDT) Thanks for your reply. But, what should I do to add a day to my original 1990.01 date string within R. And, is there a way to convert the period in my date string to hyphen? Strong Chen
Hello,
I am also new to Rmetrics so take what I say with
caution.
The string "1990.01" is not a valid date - you must
add a day also (even if you do not care about the day
add a dummy one, let say 1, so that you date is
"1990.01.01"). This is a valid date but then you have
another problem (as indicated by your error message) -
if you specify date only then the format is assumed to
be "%Y-%m-%d" and so a period (.) can not be a
separator. So you can either specify the date as
"1990-01-01" or supply a valid time as well, i.e.
timeDate("1990.02.01.00.00.01",format="%Y.%m.%d.%H.%M.%S").
Regards,
Moshe.
--- Strong <strongthinking at gmail.com> wrote:
Dear All
I am a beginner of Rmetrics. It is the first time I
posts on the mailing list.
I am having a problem with the use of timeDate
function.
I tried to use timeDate function in the fCalendar
package to convert a character string of date to
into the timeDate object.
My script is something like the followings:
< date <- c("1990.01", "1990.02")
< date.td <- timeDate(date, format="%Y.%m")
And then, I got the following error message:
Error in if (sum(lt$sec + lt$min + lt$hour) == 0)
isoFormat = "%Y-%m-%d" :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown Format Specification in:
.whichFormat(charvec)
I don't know what's wrong with my format
specification. It seems the reason is I am not
using the standard iso format, although I do
believe the flexible specification of time format is
allowed by the timeDate function just like in
S-Plus.
Can anyone help me?
Thanks in advance.
Strong Chen
phd Student, Graduate School of Commerce and
Management;
Hitotusbashi University, Tokyo, Japan
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
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
From: Moshe Olshansky <m_olshansky at yahoo.com> Subject: Re: [R-SIG-Finance] Problem with the timeDate function Date: Sun, 23 Sep 2007 17:14:04 -0700 (PDT) Thanks for your reply. But, what should I do to add a day to my original 1990.01 date string within R. And, is there a way to convert the period in my date string to hyphen? Strong Chen
Hello,
I am also new to Rmetrics so take what I say with
caution.
The string "1990.01" is not a valid date - you must
add a day also (even if you do not care about the day
add a dummy one, let say 1, so that you date is
"1990.01.01"). This is a valid date but then you have
another problem (as indicated by your error message) -
if you specify date only then the format is assumed to
be "%Y-%m-%d" and so a period (.) can not be a
separator. So you can either specify the date as
"1990-01-01" or supply a valid time as well, i.e.
timeDate("1990.02.01.00.00.01",format="%Y.%m.%d.%H.%M.%S").
Regards,
Moshe.
--- Strong <strongthinking at gmail.com> wrote:
Dear All
I am a beginner of Rmetrics. It is the first time I
posts on the mailing list.
I am having a problem with the use of timeDate
function.
I tried to use timeDate function in the fCalendar
package to convert a character string of date to
into the timeDate object.
My script is something like the followings:
< date <- c("1990.01", "1990.02")
< date.td <- timeDate(date, format="%Y.%m")
And then, I got the following error message:
Error in if (sum(lt$sec + lt$min + lt$hour) == 0)
isoFormat = "%Y-%m-%d" :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown Format Specification in:
.whichFormat(charvec)
I don't know what's wrong with my format
specification. It seems the reason is I am not
using the standard iso format, although I do
believe the flexible specification of time format is
allowed by the timeDate function just like in
S-Plus.
Can anyone help me?
Thanks in advance.
Strong Chen
phd Student, Graduate School of Commerce and
Management;
Hitotusbashi University, Tokyo, Japan
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.