[R-SIG-Finance] I have a problem with zoo object
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Feb 5 22:44:07 CET 2011
On Sat, Feb 5, 2011 at 2:31 PM, B. Jonathan B. Jonathan
<bkheijonathan at gmail.com> wrote:
> Hi all, can somebody correct me where I was wrong in following set of codes?
> I have a list where each element is zoo object and I want to call a
> particular zoo object through some assigned name, as follows:
>
>> library(zoo)
>> List <- vector("list", length=2)
>> names(List) <- LETTERS[1:2]
>> List[[1]] <- zooreg(rnorm(10), start=as.Date("2000-01-01"), frequency=1)
>> List[[2]] <- zooreg(rnorm(20), start=as.Date("2000-01-01"), frequency=11)
>> #List
>> namess <- "A"
>> window(List$namess, start=as.Date("2000-01-01"),
> end=as.Date("2000-01-01"))
> Error in attr(x, "tsp") <- c(1, NROW(x), 1) :
> attempt to set an attribute on NULL
List$namess is the same as List[["namess"]] and there is no "namess"
component of List. You probably wanted:
window(List[[namess]], start=as.Date("2000-01-01"), end=as.Date("2000-01-01"))
or just
List[[namess]][as.Date("2000-01-01")]
or
start(List[[namess]])
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-SIG-Finance
mailing list