Folks,
I'm trying to learn `its' and am stuck on many basics. Could you
please help? I am on R 1.9.1 (2004-06-21) on Linux 2.4.17 #2. My its
version says
Packaged: Tue Apr 27 13:38:25 2004; HeywoodG
Built: R 1.9.0; ; 2004-04-28 15:03:13; unix
This part flows fine --
library(its)
x1 <- newIts(start="2000-01-01", end="2000-01-10",
1:30, ncol=3)
print(x1)
x2 <- newIts(start="2000-01-01", end="2000-01-10",
1:30, ncol=3,
extract=T, weekday=T)
print(x2)
Now I get into trouble --
str(x1) # works
str(x2) # BREAKS
For the str(x2) it says "Error in object[1:ile] : subscript out of
bounds"
Is this a bug?
I try to go on.
# Let's try writing and reading --
writecsvIts(x1, filename="/tmp/try.1")
y <- its(readcsvIts(filename="/tmp/try.1"))
print(y) # looks fine
print(x1) # looks fine
y-x1 # BREAKS
For the "y-x1" command, he says "Error in y - x1 : dates must
match".
But when I look at y and x1, the dates do seem to match.
I read in two of my own data files like this --
nifty.its <- readcsvIts(filename="nifty.d", header=F, sep="
",
col.names=c("date", "r.nifty"),
informat=its.format("%Y%m%d"),
outformat=its.format("%Y-%m-%d"))
inrusd.its <- readcsvIts(filename="inrusd.d", header=F,
sep=" ",
col.names=c("date", "r.inrusd"),
informat=its.format("%Y%m%d"),
outformat=its.format("%Y-%m-%d"))
These seem to be fine. To help you diagnose my problem, I have put the
results of dput() for both these at the end. Now when I say:
> union(nifty.its, inrusd.its)
[1] 1.0149431 1.0093692 1.0126526 0.9845319 0.9804095 0.9846924 1.0105904
[8] 1.0311819 0.9986636 0.9950831 0.9922442 0.9510527 0.9833306 1.0131162
[15] 0.9966518 0.9970885 1.0000000 1.0065139 1.0093729 0.9991156 0.9975658
[22] 1.0042147 1.0039761 0.9988999 0.9955947 0.9953540 1.0046677 0.9993363
[29] 1.0015497 1.0022104 0.9984561
I find this odd: I thought union() was supposed to give me an its
object.
> intersect(nifty.its, inrusd.its)
numeric(0)
I find this odd: the two series have plenty of dates in common. And, I
thought intersect() would produce an its object.
Here's the dput results for nifty.its and inrusd.its --
> dput(nifty.its)
structure(c(1.01494311428086, 1.00936924878702, 1.01265263274214,
0.984531863814928, 0.980409543074067, 0.98469241317728, 1.01059040709914,
1.03118189975644, 0.998663641731672, 0.995083089562457, 0.992244183137353,
0.951052697932426, 0.983330571665286), .Dim = as.integer(c(13,
1)), .Dimnames = list(c("2004-05-04", "2004-05-05",
"2004-05-06",
"2004-05-07", "2004-05-10", "2004-05-20",
"2004-05-21", "2004-05-24",
"2004-05-25", "2004-05-26", "2004-05-27",
"2004-05-28", "2004-05-31"),
"r.nifty"))> dput(inrusd.its)
structure(c(1.01311623699683, 0.996651785714286, 0.997088465845465,
1, 1.00651392632525, 1.00937290783307, 0.999115631218218, 0.997565833148927,
1.00421472937001, 1.00397614314115, 0.998899889989, 0.995594713656388,
0.995353982300885, 1.00466770393421, 0.99933628318584, 1, 1.00154970112907,
1.00221043324492, 0.998456109395677), .Dim = as.integer(c(19,
1)), .Dimnames = list(c("2004-05-03", "2004-05-05",
"2004-05-06",
"2004-05-07", "2004-05-10", "2004-05-11",
"2004-05-12", "2004-05-13",
"2004-05-14", "2004-05-17", "2004-05-18",
"2004-05-19", "2004-05-20",
"2004-05-21", "2004-05-24", "2004-05-25",
"2004-05-26", "2004-05-27",
"2004-05-28"), "r.inrusd"))
--
Ajay Shah Consultant
ajayshah at mayin.org Department of Economic Affairs
http://www.mayin.org/ajayshah Ministry of Finance, New Delhi