[R] A problem on zoo object

David Winsemius dwinsemius at comcast.net
Sat Jul 4 17:30:01 CEST 2009


I looked at the question and Gabor's reply and could not figure out  
why you were not simply replacing the function list() for head() in  
the second line of his example. Or perhaps you were, and the result  
was not what you wanted, in which case it would be of you not being  
clear about the desired output. Either way a response seemed  
unwarranted.

-- 
DW
On Jul 4, 2009, at 2:51 AM, Bogaso wrote:

>
> No reply yet. Is my question not clear? Please let me know.
>
> Thanks
>
>
> Bogaso wrote:
>>
>> Thanks Gabor for this reply. However can please clarify one more  
>> thing?
>> How I want to create a list,
>> wherein each member of that list is the monthly observations. For  
>> example,
>> 1st member of list contains daily observation of 1st month, 2nd  
>> member
>> contains daily observation of 2nd month etc.
>>
>> Thanks
>>
>>
>>
>>
>> Gabor Grothendieck wrote:
>>>
>>> Try this:
>>>
>>> z <- zooreg(1:365, start = as.Date("2001-01-01"), freq = 1)
>>> f <- head
>>> tapply(seq_along(z), as.yearmon(time(z)), function(ix) f(z[ix]))
>>>
>>> where you should replace f with a function that does whatever
>>> you want with each month's data.  Here we just used head as
>>> an example.
>>>
>>>
>>> On Wed, Jul 1, 2009 at 5:17 AM, Bogaso<bogaso.christofer at gmail.com>
>>> wrote:
>>>>
>>>> I have a zoo object on daily data for 10 years. Now I want to  
>>>> create a
>>>> list,
>>>> wherein each member of that list is the monthly observations. For
>>>> example,
>>>> 1st member of list contains daily observation of 1st month, 2nd  
>>>> member
>>>> contains daily observation of 2nd month etc.
>>>>
>>>> Then for a particular month, I want to divide all observations  
>>>> into 3
>>>> parts
>>>> (arbitrary) and then want to calculate some statistics on each  
>>>> part for
>>>> each
>>>> month. Therefore for a particular month, I will have 3 means  
>>>> (suppose,
>>>> statistic is mean).
>>>>
>>>> Can anyone throw some light on how to do that?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/A-problem-on-zoo-object-tp24286720p24286720.html
>>>> Sent from the R help mailing list archive at Nabble.com.
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/A-problem-on-zoo-object-tp24286720p24331752.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list