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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:01:17+00:00 2026-05-25T21:01:17+00:00

I have an xts object ‘foo’ containing the top 6 largest negative percentage changes

  • 0

I have an xts object ‘foo’ containing the top 6 largest negative percentage changes in the value of the share price of a stock over a certain period. Using sort(foo) produces a list sorted by date, as shown below, but I want to sort the list based on the values.

sort(coredata(foo)) gives me the list I expect, but returns the values without the associated index date value, as shown below. I would like a list in the format:

2008-11-07 -0.150
2008-11-06 -0.145

etc

I feel that some combination of index() and which() might work but haven’t been able to produce anything useful. Any pointers gratefully received.

sort(foo)

   [,1]
2008-10-08 -0.105
2008-10-16 -0.119
2008-10-27 -0.109
2008-11-06 -0.145
2008-11-07 -0.150
2008-12-12 -0.121

sort(coredata(foo))
[1] -0.150 -0.145 -0.121 -0.119 -0.109 -0.105
  • 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-25T21:01:18+00:00Added an answer on May 25, 2026 at 9:01 pm

    Something along the lines of this would give you the dates in the desired order:

     index(foo)[ order(coredata(foo)) ]
    

    xts and zoo objects do not like to be displayed out of order, so I think you would need to coerce them to a less “order”-ly class:

    > foo3 <- as.data.frame(foo)
    > foo3[order(foo3$V1), ]
    [1] -0.150 -0.145 -0.121 -0.119 -0.109 -0.105
    > foo3[order(foo3$V1), ,drop=FALSE]
                   V1
    2008-11-07 -0.150
    2008-11-06 -0.145
    2008-12-12 -0.121
    2008-10-16 -0.119
    2008-10-27 -0.109
    2008-10-08 -0.105
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xts object (stock price time series) that is comprised of intraday
I have three vectors in an xts R object. Call them V1, V2, V3.
I have an xts object, the first column of which is date-time, followed by
I have an xts object that has intraday data: head(stocks[,1]) SMH.close 2009-01-02 09:31:00 17.66
I have some imported csv data that I have turned into an xts object.
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 object, x. I want to run a for loop until
I have one main XTS object Data with ~1M rows spanning 22 days. I
Have you guys had any experiences (positive or negative) by placing your source code/solution
I have an XTS timeseries in R of the following format and am trying

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.