Re: [R] time extraction and normalization

2012-10-16 Thread John Kane
> > - Original Message - > From: Simon Knapp > To: Jeff Newmiller > Cc: r-help@r-project.org; york8866 > Sent: Tuesday, October 16, 2012 1:32 AM > Subject: Re: [R] time extraction and normalization > > toDaySecond <- function(date.string, format.st

Re: [R] time extraction and normalization

2012-10-16 Thread arun
roject.org; york8866 Sent: Tuesday, October 16, 2012 1:32 AM Subject: Re: [R] time extraction and normalization toDaySecond <- function(date.string, format.string='%d%b%Y:%T', tz='') {     d <- as.POSIXct(d, format=format.string, tz=tz)     sum(mapply(function(f, l) as

Re: [R] time extraction and normalization

2012-10-16 Thread Simon Knapp
in as.POSIXct(d, format = format.string, tz = tz) : > #object 'd' not found > > A.K. > > > > > - Original Message - > From: Simon Knapp > To: Jeff Newmiller > Cc: r-help@r-project.org; york8866 > Sent: Tuesday, October 16, 2012 1:32 AM

Re: [R] time extraction and normalization

2012-10-15 Thread Simon Knapp
toDaySecond <- function(date.string, format.string='%d%b%Y:%T', tz='') { d <- as.POSIXct(d, format=format.string, tz=tz) sum(mapply(function(f, l) as.numeric(format(d, format=f)) * l, c('%H', '%M', '%S'), c(3600, 60, 1))) } toDaySecond('04MAY2011:08:19:00') Will calculate the second of th

Re: [R] time extraction and normalization

2012-10-15 Thread Jeff Newmiller
There are multiple ways. For lack of your example, I would suggest multiplying by 24. Please post the previous context of the thread if you must post from Nabble. --- Jeff NewmillerThe .

Re: [R] time extraction and normalization

2012-10-15 Thread york8866
Thanks, The code gives the numbers in "days", how can I adjust the code to directly get the numbers in "hours"? I tried units but it did not work. Thanks1 -- View this message in context: http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275p4646298.html Sent from the R

Re: [R] time extraction and normalization

2012-10-15 Thread R. Michael Weylandt
Use something like format(as.POSIXct(xxx, format = "STRING"), format = "STRING2") where the appropriate formatting codes can be worked out using the info in ?strptime Cheers, Michael On Mon, Oct 15, 2012 at 9:32 PM, york8866 wrote: > Dear all, > > I have a series of time variables such as: > >

[R] time extraction and normalization

2012-10-15 Thread york8866
Dear all, I have a series of time variables such as: 04MAY2011:08:19:00 01JUN2011:09:44:00 28JUN2011:08:08:00 25JUL2011:07:44:00 How could I extract the time as a number, so that I can normalize the times by the first time variable? Thanks, -- View this message in context: http://r.78969