[R-SIG-Finance] I have a problem with zoo object
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Feb 5 22:46:14 CET 2011
On Sat, Feb 5, 2011 at 2:51 PM, Brian G. Peterson <brian at braverock.com> wrote:
> 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.
>
r-sig-finance has always been a primary place for zoo questions so
this question seems appropriate for the list to me. In fact it turns
out that the problem is unrelated to zoo but rather to how lists work
in R but to know that you would have to know the answer.
--
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