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 7679149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:48:42+00:00 2026-05-31T17:48:42+00:00

How would I extract the time from a series of POSIXct objects discarding the

  • 0

How would I extract the time from a series of POSIXct objects discarding the date part?

For instance, I have:

times <- structure(c(1331086009.50098, 1331091427.42461, 1331252565.99979, 
1331252675.81601, 1331262597.72474, 1331262641.11786, 1331269557.4059, 
1331278779.26727, 1331448476.96126, 1331452596.13806), class = c("POSIXct", 
"POSIXt"))

which corresponds to these dates:

"2012-03-07 03:06:49 CET" "2012-03-07 04:37:07 CET" 
"2012-03-09 01:22:45 CET" "2012-03-09 01:24:35 CET" 
"2012-03-09 04:09:57 CET" "2012-03-09 04:10:41 CET"
"2012-03-09 06:05:57 CET" "2012-03-09 08:39:39 CET"
"2012-03-11 07:47:56 CET" "2012-03-11 08:56:36 CET"

Now, I have some values for a parameter measured at those times:

val <- c(1.25343125e-05, 0.00022890575, 
         3.9269125e-05, 0.0002285681875, 
         4.26353125e-05, 5.982625e-05, 
         2.09575e-05, 0.0001516951251, 
         2.653125e-05, 0.0001021391875)

I would like to plot val vs time of the day, irrespectively of the specific day when val was measured.

Is there a specific function that would allow me to do that?

  • 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-31T17:48:43+00:00Added an answer on May 31, 2026 at 5:48 pm

    You can use strftime to convert datetimes to any character format:

    > t <- strftime(times, format="%H:%M:%S")
    > t
     [1] "02:06:49" "03:37:07" "00:22:45" "00:24:35" "03:09:57" "03:10:41"
     [7] "05:05:57" "07:39:39" "06:47:56" "07:56:36"
    

    But that doesn’t help very much, since you want to plot your data. One workaround is to strip the date element from your times, and then to add an identical date to all of your times:

    > xx <- as.POSIXct(t, format="%H:%M:%S")
    > xx
     [1] "2012-03-23 02:06:49 GMT" "2012-03-23 03:37:07 GMT"
     [3] "2012-03-23 00:22:45 GMT" "2012-03-23 00:24:35 GMT"
     [5] "2012-03-23 03:09:57 GMT" "2012-03-23 03:10:41 GMT"
     [7] "2012-03-23 05:05:57 GMT" "2012-03-23 07:39:39 GMT"
     [9] "2012-03-23 06:47:56 GMT" "2012-03-23 07:56:36 GMT"
    

    Now you can use these datetime objects in your plot:

    plot(xx, rnorm(length(xx)), xlab="Time", ylab="Random value")
    

    enter image description here


    For more help, see ?DateTimeClasses

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop an application that would extract the following things from an
How would I extract the dollar amount from the following string some text will
I would like to extract items from this sample html, more specificly, i would
I would like to extract the GPS EXIF tag from pictures using php. I'm
I would like to extract a value or its inverse from database. I would
I would like to extract only tar.gz from the following strings. /root/abc/xzy/file_tar_src-5.2.8.23.tar.gz or /root/abc/xyz/file_tar_src-5.2.tar.gz
Hello! I would like to extract all citations from a text. Additionally, the name
I would like to extract the data groups from the PHP arrays depending on
I have a database from where i need to extract quite a lot of
I am trying to extract numbers from a typical scoreboard that you would find

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.