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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:46:23+00:00 2026-05-31T14:46:23+00:00

I hope I have a simple question for you all, but working with dates

  • 0

I hope I have a simple question for you all, but working with dates in R has been a difficulty for me

I have a time series data that looks like this

Month  Day  Year  Hour  Min  Sec Data
2       1    2012  1     0   0    56
2       1    2012  1     1   0    57
2       1    2012  1     2   0    52
2       1    2012  1     3   0    55
2       1    2012  1     4   0    57

My hope is to create a single date from the multiple columns and then plot the Data column by the date. My hopelessy oversimplified code would look like this:

Date1<-c(Month,Day,Year,Hour,Min,Sec)# For when hourly data is important
Date2<-c(Month,Day,Year) #For when daily data is important
as.Date(Date1)
as.Date(Date2)
plot(Data~ Date1)

I know it does not work, but I hope it can get the point across of what I am looking to accomplish.
Any ideas on how one might go about doing this?

Thanks ahead of time!

  • 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-31T14:46:25+00:00Added an answer on May 31, 2026 at 2:46 pm

    You want the ISOdatetime() function:

    R> mytimes <- ISOdatetime(2012,1,2,1,2,c(3.123,3.456,3.789),tz="UTC")
    R> mytimes
    [1] "2012-01-02 01:02:03.122 UTC" "2012-01-02 01:02:03.456 UTC" 
    [3] "2012-01-02 01:02:03.789 UTC"
    

    And these are real POSIXct objects:

    R> diff(mytimes)
    Time differences in secs
    [1] 0.333 0.333
    attr(,"tzone")
    [1] "UTC"
    R> 
    

    I made my life easier here for the example and had just one argument vectorised. But with your data in a variable mydf, say, you could do

    mytimes <- with(mydf, ISOdatetime(Year, Month, Day, Hour, Min, Sec))
    

    and you should be set and ready for plotting. You can also re-assign the mytimes column to the original data.frame.

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

Sidebar

Related Questions

Simple (I hope), HTML question. Let's say I have a column group that spans
I have a quick and hopefully simple question that I hope someone can help
I'm sure some variation of this question has been asked before but all other,
i have pretty simple simple question (i hope so). How do i change the
I have a simple question about Java's XML API and I hope there's a
Well, I have a simple question, at least I hope its simple. I was
I'm trying to learn WPF, so here's a simple question, I hope: I have
I have what I hope is a fairly simple question about using the value
I have what I hope is a simple question pertaining to the Atmel AVR
I hope this is not a duplicate of a question, but I have three

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.