Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6969601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:36:07+00:00 2026-05-27T16:36:07+00:00

I’m trying to format the answer from subtracting 2 times. Here’s an example: >

  • 0

I’m trying to format the answer from subtracting 2 times.

Here’s an example:

> timer2$tdif2 <- as.numeric(strptime(as.character(timer2$time3), "%H:%M:%S:%OS") - strptime(as.character(timer2$time2), "%H:%M:%S:%OS"))
> timer2$tdif1 <- as.numeric(strptime(as.character(timer2$time2), "%H:%M:%S%OS") - strptime(as.character(timer2$time1), "%H:%M:%S%OS"))
> timer2$tdif2 <- as.numeric(strptime(as.character(timer2$time3), "%H:%M:%S:%OS") - strptime(as.character(timer2$time2), "%H:%M:%S:%OS"))
> timer2$tdifMax <- as.numeric(strptime(as.character(timer2$time3), "%H:%M:%S.%OS") - strptime(as.character(timer2$time1), "%H:%M:%S.%OS"))
> head(timer2)
         time1        time2        time3         tdif1 tdif2 tdifMax
1 08:00:20.799 08:00:20.799 08:00:20.799  0.0000000000    NA       0
2 08:00:21.996 08:00:22.071 08:00:23.821 -0.9249999523    NA       2
3 08:00:29.200 08:00:29.200 08:00:29.591  0.0000000000    NA       0
4 08:00:31.073 08:00:31.372 08:00:31.384  0.2990000248    NA       0
5 08:00:31.867 08:00:31.867 08:00:31.971  0.0000000000    NA       0
6 08:00:37.174 08:00:38.073 08:00:38.153 -0.1010000706    NA       1

I’ve used a different formatting formula for parts of a second in tdif1, tdif2 and tdif3 but none of them give the answer in seconds and parts of a second (for tdif[2] it should be .075). Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:36:07+00:00Added an answer on May 27, 2026 at 4:36 pm

    You got the format wrong, your data is in "%H:%M:%OS" format. Also I’d suggest you do the math in numerics – that gives you always seconds.

    So your example:

    sec <- function(x) as.numeric(strptime(x, "%H:%M:%OS"))
    
    timer2$tdif1   <- sec(timer2$time2) - sec(timer2$time1)
    timer2$tdif2   <- sec(timer2$time3) - sec(timer2$time2)
    timer2$tdifMax <- sec(timer2$time3) - sec(timer2$time1)
    

    and the output:

    > head(timer2)
             time1        time2        time3      tdif1      tdif2   tdifMax
    1 08:00:20.799 08:00:20.799 08:00:20.799 0.00000000 0.00000000 0.0000000
    2 08:00:21.996 08:00:22.071 08:00:23.821 0.07500005 1.75000000 1.8250000
    3 08:00:29.200 08:00:29.200 08:00:29.591 0.00000000 0.39100003 0.3910000
    4 08:00:31.073 08:00:31.372 08:00:31.384 0.29900002 0.01200008 0.3110001
    5 08:00:31.867 08:00:31.867 08:00:31.971 0.00000000 0.10399985 0.1039999
    6 08:00:37.174 08:00:38.073 08:00:38.153 0.89899993 0.08000016 0.9790001
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.