[R-SIG-Finance] I have a problem with zoo object

Brian G. Peterson brian at braverock.com
Sat Feb 5 20:51:04 CET 2011


On 02/05/2011 01:31 PM, B. Jonathan B. Jonathan 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

This is a general question that should have gone to R-help, not here.

you don't have a slot called 'namess'

You have a string called 'namess'

So,

List[[namess]]

will work.

Please direct non-finance-specific queries to R-help in the future.

    - Brian



More information about the R-SIG-Finance mailing list