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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:07:06+00:00 2026-05-31T19:07:06+00:00

I have hourly weather data. I’ve seen the function examples from here: http://casoilresource.lawr.ucdavis.edu/drupal/node/991 I’m

  • 0

I have hourly weather data. I’ve seen the function examples from here: http://casoilresource.lawr.ucdavis.edu/drupal/node/991

I’m altering the code to account for airport data, which has a different URL type. Another issue with the airport weather data is that the time data is saved in 12 hour format. Here is a sample of the data:

14  10:43 AM
15  10:54 AM
16  11:54 AM
17  12:07 PM
18  12:15 PM
19  12:54 PM
20  1:54 PM
21  2:54 PM

Here’s what I attempted: (I see that using just ‘PM’ isn’t careful enough because any times between 12 and 1 pm will be off if they go through this alg)

date<-Sys.Date()


data$TimeEST<-strsplit(data$TimeEST, ' ')
for (x in 1:35){
    if('AM' %in% data$TimeEST[[x]]){
        gsub('AM','',data$TimeEST[[x]])
        data$TimeEST[[x]]<-str_trim(data$TimeEST[[x]])
        data$TimeEST[[x]]<-str_c(date,' ',data$TimeEST[x],':',data$TimeEST[2])
    }
    else if('PM' %in% data$TimeEST[[x]]){
        data$TimeEST[[x]]<-gsub('PM', '',data$TimeEST[[x]])
        data$TimeEST[[x]]<-strsplit(data$TimeEST[[x]], ':')
        data$TimeEST[[x]][[1]][1]<-as.integer(data$TimeEST[[x]][[1]][1])+12
        data$TimeEST[[x]]<-str_trim(data$TimeEST[[x]][[1]])
        data$TimeEST[[x]]<-str_c(date, " ", data$TimeEST[[x]][1],':',data$TimeEST[[x]][2])

    }
}

Any help?

  • 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-31T19:07:08+00:00Added an answer on May 31, 2026 at 7:07 pm

    Would strptime work?

    df2= structure(c("10:43 AM", "10:54 AM", "11:54 AM", "12:07 PM", "12:15 PM", 
                "12:54 PM", "1:54 PM", "2:54 PM"), .Dim = c(8L, 1L))
    
    
    
     strptime(df2, "%I:%M %p" )
    

    Or in case you don’t want the date, something like:
    Although it depends what kind of class would you want for the object.

    substr(strptime(df2, "%I:%M %p" ),11,19)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an hourly weather data in the following format: Date,DBT 01/01/2000 01:00,30 01/01/2000
Ok, I have had a request to implement the same function that the weather
All, I am trying to download the weather data history from Wunderground. The problem
I have a hourly dataset from 1996 - 2010 in the following format: date
Folks, I have an hourly temperature data like this Lines <- Date,Outdoor,Indoor 01/01 01:00:00,24.5,21.3
I'm querying some data from a table in DB2/z which holds hourly data but
I am trying to plot hourly meteorological data coming from a meteorological station with
I want to extract some hourly data from rrdtool databases in order to create
I have full weekly backups, daily differential backups and hourly transaction log backups. To
Have you ever seen any of there error messages? -- SQL Server 2000 Could

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.