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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:19:23+00:00 2026-05-22T18:19:23+00:00

I have 1 minute intraday price data which has missing data points. As such

  • 0

I have 1 minute intraday price data which has missing data points. As such I want to fill them.

I read through the suggestions in the following post and tried a similar procedure:
R: Filling missing dates in a time series?

In my case the missing data point is the first trade i.e. at 09:31:00.

> head(s)
                    AMR.Open AMR.High AMR.Low AMR.Close AMR.Volume AMR.WAP AMR.hasGaps AMR.Count
2010-09-10 09:32:00     6.08     6.10    6.07      6.10        298   6.087           0        39
2010-09-10 09:33:00     6.10     6.14    6.10      6.14        274   6.122           0        70
2010-09-10 09:34:00     6.14     6.15    6.13      6.13        472   6.133           0        96
2010-09-10 09:35:00     6.13     6.14    6.13      6.13        291   6.133           0        68
2010-09-10 09:36:00     6.13     6.13    6.11      6.11        548   6.123           0        97
2010-09-10 09:37:00     6.11     6.11    6.11      6.11         67   6.110           0        26

> na.locf(s, xout=seq(as.POSIXct(head(index(s), 1) - 60), as.POSIXct(tail(index(s), 1)), by="1 min")) -> ss

> head(ss)
                    AMR.Open AMR.High AMR.Low AMR.Close AMR.Volume AMR.WAP AMR.hasGaps AMR.Count
2010-09-10 09:32:00     6.08     6.10    6.07      6.10        298   6.087           0        39
2010-09-10 09:33:00     6.10     6.14    6.10      6.14        274   6.122           0        70
2010-09-10 09:34:00     6.14     6.15    6.13      6.13        472   6.133           0        96
2010-09-10 09:35:00     6.13     6.14    6.13      6.13        291   6.133           0        68
2010-09-10 09:36:00     6.13     6.13    6.11      6.11        548   6.123           0        97
2010-09-10 09:37:00     6.11     6.11    6.11      6.11         67   6.110           0        26

As you can see above the object returned is not filled as desired.

Below you can see that I correctly specified the start and end times.

> as.POSIXct(head(index(s), 1) - 60)
[1] "2010-09-10 09:31:00 EDT"

> as.POSIXct(tail(index(s), 1))
[1] "2010-09-10 16:00:00 EDT"
> 

Could this be because the date range has a time-zone specified whereas the original POSIX index does not? I tried to remove the tz by specifiying tz=”” but that does not remove it. That being said, the time-zone may be just a red herring.

I saved the data in rda (binary) format if anyone is interested in testing:

http://www.speedyshare.com/files/28576853/test.rda

Appreciate the 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-22T18:19:24+00:00Added an answer on May 22, 2026 at 6:19 pm

    na.locf operates on the data, not the index. If you want to add a row of NA to the data, you would need to make a suitable xts object to rbind to s:

    miss <- xts(matrix(1*NA,1,NCOL(s)), first(index(s))-60)
    s <- rbind(miss,s)
    s <- na.locf(s, fromLast=TRUE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which get new data inserted every minute or so. According
I have a Web server that updates its data once per minute, and want
I need to be able to display data that I have in 15 minute
I have a PHP page that I run every minute through a CRON job.
I have a web scraping script that gets new data once every minute, but
I have a form which posts date information month, day, yeah, hour, minute, am/pm.
I have a CGI script which takes about 1 minute to run. Right now
I have a minute value and i want to have to 2 string values
I have several vehicles that send a data to server each minute. The server
I have a table which gets around 10-15k entries per minute. Each one is

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.