Re: [R] Converting a number of minutes to a difftime

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 13 May 2005 - 07:15:18 EST

On Thu, 12 May 2005, Martin C. Martin wrote:

> I have a variable "m" that contains the number of minutes that something
> lasted, e.g.
>
> m <- 139
>
> I'd like to convert it to a difftime, so I can add it to the POSIXct start
> time. But as.difftime seems to want a character string, with at most two
> characters for the minutes. All other conversion functions seem to take
> strings as well. What am I missing?

as.difftime() is quite limited. You need to get your hands dirty:

    structure(m, units = "mins", class = "difftime")

will do the job.

Alternatively, Sys.time + (m*60) works.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri May 13 07:21:11 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:45 EST