Problem 1: Often, when I'm dealing with its, str() breaks. Here's a bug demo. The first statements work fine -- library(its) # Make a series of all dates from 1/1/2000 to 10/1/2000; fill this up # with integers from 1 to 30 x1 <- newIts(start="2000-01-01", end="2000-01-10", 1:30, ncol=3) print(x1) # Do the same, but restrict yourself to weekdays only x2 <- newIts(start="2000-01-01", end="2000-01-10", 1:30, ncol=3, extract=T, weekday=T) print(x2) str(x1) # works But here it breaks -- > str(x2) Error in object[1:ile] : subscript out of bounds Problem 2: I try to write an its out and read it back in, but the two don't seem to be conformable for matrix subtraction. # Let's try writing and reading -- writecsvIts(x1, filename="/tmp/try.1") y <- its(readcsvIts(filename="/tmp/try.1")) print(y) print(x1) But this breaks -- > y-x1 Error in y - x1 : dates must match (But they are identical, as the print commands show. x1 was written out and read back into y). Problem 3: How would I convert an its object into an ordinary numerical matrix or data frame? I have succeeded with statements like x <- as.numeric(itsobject[,2]) which extracts the 2nd column. But this 'wastes' the dates. How do I make a data frame out of the its object, where one of the columns is the dates? How do I make a matrix out of the its object, so that I don't have to attack one vector at a time using as.numeric() as shown above? Problem 4: I tried to do plot() and then lines() but that does not seem to work. How does one superpose multiple curves on one picture, where each of them is an its object? I will be most happy if someone can point me to more knowledge on its. It seems like a fascinating library but I'm not yet able to learn it using the standard docs. -- Ajay Shah Consultant ajayshah at mayin.org Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
On Fri, Aug 27, 2004 at 04:08:40PM +0530, Ajay Shah wrote:> Problem 1: Often, when I'm dealing with its, str() breaks. Here's a > bug demo. The first statements work fine --[...]> Problem 2: I try to write an its out and read it back in, but the two > don't seem to be conformable for matrix subtraction.[...] Those two seem like genuine its bugs to me.> Problem 3: How would I convert an its object into an ordinary > numerical matrix or data frame? I have succeeded with statementsUse itsAsDf <- core(itsObject) to turn 'itsObject' into a data.frame, as.matrix and friends take it from there.> Problem 4: I tried to do plot() and then lines() but that does not > seem to work. How does one superpose multiple curves on one picture, > where each of them is an its object?The par(new=TRUE) command allows you do that generically. I.e. to add a second object to a plot, and have it use the right axis, this works plot(Data) # plot something, sets up plot, axes, ... par(new=TRUE) # tell R we need more plot(moreData, axes=FALSE) # plot more, don't overplot x axis axis(4) # add 2nd y-axis on right Hth, Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx
>>>>> "Ajay" == Ajay Shah <ajayshah at mayin.org> >>>>> on Fri, 27 Aug 2004 16:08:40 +0530 writes:Ajay> Problem 1: Often, when I'm dealing with its, str() breaks. Here's a Ajay> bug demo. The first statements work fine -- Ajay> library(its) Ajay> # Make a series of all dates from 1/1/2000 to 10/1/2000; fill this up Ajay> # with integers from 1 to 30 Ajay> x1 <- newIts(start="2000-01-01", end="2000-01-10", 1:30, ncol=3) Ajay> print(x1) Ajay> # Do the same, but restrict yourself to weekdays only Ajay> x2 <- newIts(start="2000-01-01", end="2000-01-10", 1:30, ncol=3, Ajay> extract=T, weekday=T) Ajay> print(x2) Ajay> str(x1) # works Ajay> But here it breaks -- >> str(x2) Ajay> Error in object[1:ile] : subscript out of bounds be it an its bug or not, str() shouldn't "break". -- and it doesn't anymore in "R-devel" (aka "R 2.0.0 unstable"). There, str() has been enhanced (several weeks ago) to nicely display S4 class objects, and for the above it returns > str(x2) Formal class 'its' [package "its"] with 3 slots ..@ dim : int [1:2] 6 3 ..@ dimnames:List of 2 .. ..$ : chr [1:6] "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" ... .. ..$ : chr [1:3] "1" "2" "3" ..@ dates :`POSIXct', format: chr [1:6] "2000-01-03 01:00:00" "2000-01-04 01:00:00" "2000-01-05 01:00:00" "2000-01-06 01:00:00" ... --- Martin Maechler