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

  • Home
  • SEARCH
  • 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 7585309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:08:41+00:00 2026-05-30T19:08:41+00:00

I have an xts numeric matrix on which I need to apply many transformations.

  • 0

I have an xts numeric matrix on which I need to apply many transformations. According to this thread the object returned by transform() should be wrapped in a call to as.xts() (xts doesn’t have its own transform version and zoo returns a new object).

I’ve tried the conversion on some sample data and it seems to work fine but when I run it on my own data I get this error:

Browse[2]> class(myxts)
[1] "xts" "zoo"
Browse[2]> mode(myxts)
[1] "numeric"
Browse[2]> str(myxts)
An 'xts' object from 2011-07-22 09:30:00 to 2011-12-19 16:00:00 containing:
  Data: num [1:11606, 1:19] 0 158300 157700 157600 157900 ...
  - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:19] "Open" "High" "Low" "Close" ...
  Indexed by objects of class: [POSIXlt,POSIXt] TZ: 
  xts Attributes:  
 NULL
Browse[2]> head(myxts['2011-07-22'])
                      Open   High    Low  Close
2011-07-22 09:30:00      0      0      0      0      
2011-07-22 09:31:00 158300 158400 157600 157800     
2011-07-22 09:32:00 157700 157700 157500 157700 
2011-07-22 09:33:00 157600 157900 157599 157900
2011-07-22 09:34:00 157900 158100 157800 158100
2011-07-22 09:35:00 158000 158400 157900 158200 
Browse[2]> n
debug: myxts = as.xts(transform(myxts, Open = ifelse(Open == 
    0, NA, Open), Close = ifelse(Close == 0, NA, Close), High = ifelse(High == 
    0, NA, High), Low = ifelse(Low == 0, NA, Low)))
Browse[2]> class(myxts)
[1] "xts" "zoo"
Browse[2]> head(myxts['2011-07-22'])
Error in function (year = 1970, month = 1, day = 1, hour = 0, min = 0,  : 
  unused argument(s) (tz1 = "", tz2 = "EST", tz3 = "EDT")
Browse[2]> str(myxts)
An 'xts' object from 2011-07-22 09:30:00 to 2011-12-19 16:00:00 containing:
  Data: num [1:11606, 1:19] NA 158300 157700 157600 157900 ...
  - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:19] "Open" "High" "Low" "Close" ...
   Indexed by objects of class: [POSIXlt,POSIXt] TZ: 
  TZ: EST
  TZ: EDT
  xts Attributes:  
 NULL

NOTE

There are 2 TZ: EST/EDT fields added to the output of str(myxts) after the call to transform().

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

    I think the problem is in a mismatch between the TZ index set by as.xts() and xts(). My TZ environment variable is not set and the original xts object was created without a specific TZ value, as reported by str().

    However, after the call to transform() and as.xts(), the TZ index is set to EST/EDT. as.xts() probably gets the time zone from some other source than the env variable.

    By forcing the TZ index to an empty string (or whatever TZ env variable value) I was able to restore indexing selection in the as.xts() object:

    indexTZ(myxts) = Sys.getenv("TZ")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xts object, the first column of which is date-time, followed by
I have an xts object, for example ts=xts(seq(10),seq(Sys.Date(),Sys.Date()+10,length.out=10)) and need to add a new
I have an xts numeric matrix that includes multiple days of minute interval series.
I have three vectors in an xts R object. Call them V1, V2, V3.
I have a xts object (stock price time series) that is comprised of intraday
I have some imported csv data that I have turned into an xts object.
I have an xts object that has intraday data: head(stocks[,1]) SMH.close 2009-01-02 09:31:00 17.66
have this code import threading def Thread(f): def decorator(*args,**kargs): print(args) thread = threading.Thread(target=f, args=args)
I have an xts object, x. I want to run a for loop until
I am trying to divide an xts object which holds a number of time

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.