How to set up an ITS object, just the basics?
(Post manually approved; Taher you may want to subscribe to the list with this address --Dirk)
On Thu, Sep 30, 2004 at 03:22:31PM +0100, Taher Khan wrote:
Greetings! Apologize for bringing up a really simple question, unfortunately I cannot make sense of the help file for ITS. I have a dataframe dfNAV which consists of a POSIXct date value %d/%m/%Y and two values, some of which are NA's. I want to set up an ITS object so that I can use locf(). Can someone please explain the syntax for setting it up? For example: dfNAV.its <- its(as.matrix(dfNAV), format = '%d-%m-%Y') Is it not working because I already have a date value, should I convert it to a string before trying to make it an ITS?
It is really all there in the docs. The example section of help(its) has
mat <- structure(1:6,dim=c(2,3),dimnames=list(c("2003-01-01","2003-01-04"),letters[1:3]))
which creates a matrix. Try class(mat), and then try class(its(mat)).
Similarly
times <- as.POSIXct(strptime(c("1999-12-31 01:00:00","2000-01-01 02:00:00"),format="%Y-%m-%d %X"))
creates a POSIXct object which you can then use as the second argument to
its() -- try class(times) and class(its(mat,times)).
So in a nutshell, you can create its objects either way. I tend to fill the
data and time components as two components, so
myIts <- its(myData, myDatesAsPosix)
would be my choice.
Hope this helps, Dirk
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx