[R] time segments intersection

[Ricardo Rodriguez] Your XEN ICT Team webmaster at xen.net
Fri Oct 3 01:15:52 CEST 2008


Thanks Gabor,

I am afraid I have some problems installing zoo package. Please, could 
you take a look at this?

 > install.packages("packagename",repos="http://R-Forge.R-project.org")
Warning message:
package 'packagename' is not available
 > install.packages("zoo",repos="http://R-Forge.R-project.org")
trying URL 
'http://R-Forge.R-project.org/bin/macosx/universal/contrib/2.7/zoo_1.6-0.tgz'
Content type 'application/x-gzip' length 651053 bytes (635 Kb)
opened URL
==================================================
downloaded 635 Kb

/bin/sh: tar: command not found
Error in sprintf(gettext(fmt, domain = domain), ...) :
  argument is missing, with no default


Here the detailsl of my system...

 > version
               _                          
platform       i386-apple-darwin8.11.1    
arch           i386                       
os             darwin8.11.1               
system         i386, darwin8.11.1         
status                                    
major          2                          
minor          7.2                        
year           2008                       
month          08                         
day            25                         
svn rev        46428                      
language       R                          
version.string R version 2.7.2 (2008-08-25)
 >

Any idea? Thanks!!!

Ricardo


Gabor Grothendieck wrote:
> Try this:
>
>   
>> library(zoo)
>> # create two time series to test with
>> z1 <- zooreg(0:10, Sys.Date())
>> z2 <- lag(z1, 5)
>>
>> z1
>>     
> 2008-10-02 2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07
> 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12
>          0          1          2          3          4          5
>     6          7          8          9         10
>   
>> z2
>>     
> 2008-09-27 2008-09-28 2008-09-29 2008-09-30 2008-10-01 2008-10-02
> 2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07
>          0          1          2          3          4          5
>     6          7          8          9         10
>   
>> # intersect them
>> merge(z1, z2, all = FALSE)
>>     
>            z1 z2
> 2008-10-02  0  5
> 2008-10-03  1  6
> 2008-10-04  2  7
> 2008-10-05  3  8
> 2008-10-06  4  9
> 2008-10-07  5 10
>   
>> range(time(merge(z1, z2, all = FALSE)))
>>     
> [1] "2008-10-02" "2008-10-07"
>
> On Wed, Oct 1, 2008 at 12:48 PM, [Ricardo Rodriguez] Your XEN ICT Team
> <webmaster at xen.net> wrote:
>   
>> Hi all,
>>
>> Please, how could I calculate the time that two time segments has in common?
>> Is there any function to perform this calculation?
>>
>> For instance, given four POSIXlt objects...
>>
>> endPeriod<-as.POSIXlt("2008-09-30")
>> startPeriod<-as.POSIXlt("2007-10-01")
>> endProject<-as.POSIXlt("2007-05-31")
>> startProject<-as.POSIXlt("2006-12-01")
>>
>> that limit two time segments...
>>
>> project <- as.numeric(endProject-startProject)
>> period <- as.numeric(endPeriod-startPeriod)
>>
>> How could I calculate the time project and period overlap?
>>
>> Thanks for your help!
>>
>> Ricardo
>>
>>
>>
>> --
>> Ricardo Rodríguez
>> Your XEN ICT Team
>>
>> ______________________________________________
>> 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.
>>
>>     
>
>   


-- 
Ricardo Rodríguez
Your XEN ICT Team



More information about the R-help mailing list