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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:25:18+00:00 2026-05-31T06:25:18+00:00

I have a zoo object in R that has daily data and is missing

  • 0

I have a zoo object in R that has daily data and is missing the weekends. When I try to run some functions (for example ar() ) on the object i get the error:

mkt.ar <- ar(zoo_object)
Error in na.fail.default(as.ts(x)) : missing values in object

If I do:

mkt.ar <- ar(zoo_object, na.action=na.omit)
Error in na.omit.ts(as.ts(x)) : time series contains internal NAs

This makes sense since when zoo tries to convert things to ts, the weekends are inherently missing. Other than converting things to a vector using coredata(zoo_object) and running ar() on that, is there a way to tell R to skip the missing data?

Thanks

  • 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-31T06:25:20+00:00Added an answer on May 31, 2026 at 6:25 am

    I gather that every day is represented in your data including weekdays and weekends but the days for which no data is present are NA (as opposed to not being present at all). In the future please provide some test data for better clarity.

    Aside from your solution, if you have enough data you could perform an ar on weekly data only by extracting the last non-missing value on or before Friday:

    library(zoo)
    
    # test data
    library(chron) # is.weekend
    z <- zoo(100:130, as.Date("2000-01-01") + 0:30)
    z[is.weekend(time(z))] <- NA
    
    # extract Fridays
    zfri <- na.locf(z)[format(time(z), "%w") == 5]
    

    (If there are no missing Fridays it can be shortened by replacing na.locf(z) with z.)

    Another possibility is to use 1, 2, … for the times but give them names in which case you could always find out what date a point belongs to by checking the name of its time.

    z1 <- na.omit(z)
    time(z1) <- setNames(seq_along(z1), time(z1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a zoo with daily data that looks like this: > head(almorol) 1973-10-02
I have some imported csv data that I have turned into an xts object.
I have some data that looks a bit like this: require(zoo) X <- rbind(c(date='20111001',
I have a zoo object oi.zoo with weekly data. I would like to sooth
I have to make a program that has a zoo with three types of
For example, I have an ArrayList: ArrayList<Animal> zoo = new ArrayList<Animal>(); // some code
I have a yearmon object: require(zoo) date1 <- as.yearmon(Mar 2012, %b %Y) class(date1) #
I have a df/zoo/xts/whatever that is split by day of week. I'd like to
I have a large data frame (named z ) that looks like this: RPos
I have a zoo time series object, vels : 2011-05-01 00:00:00 7.52 2011-05-01 00:10:00

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.