Skip to content

Converting a number of minutes to a difftime

2 messages · Martin C. Martin, Brian Ripley

#
Hi,

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?

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

            
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.