[R] Help with POSIX

David Wolfskill r at catwhisker.org
Tue Mar 31 04:13:39 CEST 2015

On Tue, Mar 31, 2015 at 01:15:09AM +0000, Doran, Harold wrote:
> I?m struggling a bit with learning about POSIX objects to do some basic things with objects of this class. Suppose I have the following simple example
> times <- c("03:20", "29:56", "03:30", "21:03", "56:26")
> aa <- strptime(times, "%M:%S?)
> I can do means, and some other basic things, but I cannot correlate the objects with some other variable
> cor(aa, rnorm(5))

I suspect you will find that manipulating times as numeric quantities
(so you can do arithmetic on them) will be easier if you convert to
seconds (possibly using a different vector, leaving "times" as it was).

> Also, for purposes of a user-interface I have built with shiny, I need for the time to be viewed as simply as minutes:seconds, such as this
> format(aa, '%M:%S?)
> But of course after doing this I lose the ability to work with this object as a time variable.

So do that with a copy -- the output of format() need not destroy its


David H. Wolfskill				r at catwhisker.org
Those who murder in the name of God or prophet are blasphemous cowards.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 949 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150330/3851a8ba/attachment.bin>

More information about the R-help mailing list