Re: [R] time segments intersection

2008-10-04 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks. Gabor Grothendieck wrote: Assuming the first row is the comparison row convert to Date class and calculate: DF[] <- lapply(DF, as.Date, format = "%Y/%m/%d") pmin(DF[[2]], DF[1, 2]) - pmax(DF[[1]], DF[1,1]) Please be explicit next time in formulating your queries as requested in the las

Re: [R] time segments intersection

2008-10-04 Thread Gabor Grothendieck
Assuming the first row is the comparison row convert to Date class and calculate: DF[] <- lapply(DF, as.Date, format = "%Y/%m/%d") pmin(DF[[2]], DF[1, 2]) - pmax(DF[[1]], DF[1,1]) Please be explicit next time in formulating your queries as requested in the last line of every message to r-help. O

Re: [R] time segments intersection

2008-10-04 Thread [Ricardo Rodriguez] Your XEN ICT Team
Gabor Grothendieck wrote: Mark did not post his response so I don't know what it is. This is Mark's proposal. Sorry, I was speaking about it as if posted to the list. # MAKE POSIXct OBJECTS FROM CHARACTER STRINGS temp1 <- as.POSIXct(strptime("2007-02-02","%Y-%m-%d")) temp2 <- as.POSIXct(

Re: [R] time segments intersection

2008-10-03 Thread Gabor Grothendieck
On Fri, Oct 3, 2008 at 7:47 PM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Hi! > > > [Ricardo Rodriguez] Your XEN ICT Team wrote: >> >> Thanks Gabor, >> >> Gabor Grothendieck wrote: >>> >>> If those do not work try installing some other packages, e.g. chron, >>> to see if yo

Re: [R] time segments intersection

2008-10-03 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi! [Ricardo Rodriguez] Your XEN ICT Team wrote: Thanks Gabor, Gabor Grothendieck wrote: If those do not work try installing some other packages, e.g. chron, to see if you can install anything. If you still have problems there is something wrong with your installation. Ask on the r-sig-mac

Re: [R] time segments intersection

2008-10-03 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Gabor, Gabor Grothendieck wrote: If those do not work try installing some other packages, e.g. chron, to see if you can install anything. If you still have problems there is something wrong with your installation. Ask on the r-sig-mac list. You are right: something is wrong with

Re: [R] time segments intersection

2008-10-03 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Mark! Mark Leeds wrote: Hi Ricardo: My date knowledge is mostly restricted to as.POSIXct so I don't know what else to tell you. Did you ever work out that zoo downloading problem because Gabor's solutions are usually excellent. I've not worked out the problems I am facing while installin

Re: [R] time segments intersection

2008-10-03 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Hadley, hadley wickham wrote: Also ensure that you have an up-to-date version of R. Hadley I think the most recent release... > version _ platform i386-apple-darwin8.11.1 arch i386 os da

Re: [R] time segments intersection

2008-10-03 Thread hadley wickham
> Its as follows: > > chooseCRANmirror() > install.packages("zoo", dep = TRUE) > > or maybe: > > chooseCRANmirror() > install.packages("zoo", dep = TRUE, type = "mac.binary") > > If those do not work try installing some other packages, e.g. chron, > to see if you can install anything. If you still

Re: [R] time segments intersection

2008-10-03 Thread Gabor Grothendieck
On Fri, Oct 3, 2008 at 2:48 AM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Thanks Gabor, > > Gabor Grothendieck wrote: >> >> Try: >> >> chooseCRANmirror() > > It works the call to the pop-up window, but it fails now whatever mirror I > use with the following message: > >> in

Re: [R] time segments intersection

2008-10-03 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Mark, [EMAIL PROTECTED] wrote: # MAKE POSIXct OBJECTS FROM CHARACTER STRINGS temp1 <- as.POSIXct(strptime("2007-02-02","%Y-%m-%d")) temp2 <- as.POSIXct(strptime("2007-02-01","%Y-%m-%d")) # TEMP1 AND TEMP2 ARE SORT OF NUMBERS BUT EACH UNIT IS ONE # SECOND result <- difftime(temp1,temp2

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Gabor, Gabor Grothendieck wrote: Try: chooseCRANmirror() It works the call to the pop-up window, but it fails now whatever mirror I use with the following message: > install.packages("zoo",repos=chooseCRANmirror()) /bin/sh: tar: command not found Error in sprintf(gettext(fmt, domain

Re: [R] time segments intersection

2008-10-02 Thread Gabor Grothendieck
Try: chooseCRANmirror() On Thu, Oct 2, 2008 at 7:47 PM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > OK. Please, how do I force the select directory window to pop-up after > selecting a given repos and without restarting R? > > When I submit install.packages("zoo", dep = TRU

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
Not yet. I'll keep trying. Please, what format string must I pass to strptime to get the date as a number? Thanks. Cheers, Ricardo [EMAIL PROTECTED] wrote: did you get zoo to work and try gabor's solution because i wasn't really following what you wanted. On Thu, Oct 2, 2008 at 7:25 P

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
OK. Please, how do I force the select directory window to pop-up after selecting a given repos and without restarting R? When I submit install.packages("zoo", dep = TRUE) for the first time after R starts, I am required to select a mirror. But this doesn't happen in the next install command at

Re: [R] time segments intersection

2008-10-02 Thread Gabor Grothendieck
Select a different mirror until you find one that works for you. On Thu, Oct 2, 2008 at 7:38 PM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Hi, > > Gabor Grothendieck wrote: >> >> Try this: >> >> install.packages("zoo", dep = TRUE) > > Here the result. I've tried with a cou

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi, Gabor Grothendieck wrote: Try this: install.packages("zoo", dep = TRUE) Here the result. I've tried with a couple of mirrors (Bristol and Spain): > install.packages("zoo", dep = TRUE) --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for reposit

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi Mark, [EMAIL PROTECTED] wrote: hi: I don't know if it's the best way but one way is to use an POSIXct object. ( you can convert using as.POSIXct( strptime(datestring)) because then each unit of digit is a second and you can proceed from there. if you explain what you want to do exactly,

Re: [R] time segments intersection

2008-10-02 Thread Gabor Grothendieck
Try this: install.packages("zoo", dep = TRUE) On Thu, Oct 2, 2008 at 7:15 PM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Thanks Gabor, > > I am afraid I have some problems installing zoo package. Please, could you > take a look at this? > >> install.packages("packagename"

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
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

Re: [R] time segments intersection

2008-10-02 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi John, John Kane wrote: help("%in%") may be of use. However I don't see any overlap in your example. You are right! I've choosen an example where the intersection is 0. But we could consider this other case... endPeriod<-as.POSIXlt("2008-09-30") startPeriod<-as.POSIXlt("2007-10-01") endP

Re: [R] time segments intersection

2008-10-02 Thread Gabor Grothendieck
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

Re: [R] time segments intersection

2008-10-02 Thread John Kane
help("%in%") may be of use. However I don't see any overlap in your example. --- On Wed, 10/1/08, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > From: [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> > Subject: [R] time seg

[R] time segments intersection

2008-10-01 Thread [Ricardo Rodriguez] Your XEN ICT Team
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") st