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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:53:00+00:00 2026-06-13T02:53:00+00:00

I was wondering if there is an implementation in R where it sorts a

  • 0

I was wondering if there is an implementation in R where it sorts a permutation of n numbers into the original 1…n sequence and provides the number of reversals needed. Eg an implementation of the “sorting by reversals” or “sorting by translocation” as outlined in this ppt.

Specifically, I have a permutation of a sequence of n elements, pi(n), and I want to figure out how close it is to the original sequence. The number of reversals seems a good metric.

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-06-13T02:53:01+00:00Added an answer on June 13, 2026 at 2:53 am

    This seems like a job for Kendall’s distance (also known, sometimes, as the Bubble-sort distance). It is probably the most commonly used metric to measure distance in ranking space.

    The Kendall distance counts the number of times that two sequences differ in their ordering of the items in two indices. In the case that one of the sequences is the trivial sequence (1, 2, …, n), we can measure the distance simply by counting the number of times that i < j and pi(i) > pi(j).

    If you like this metric (it is equivalent to the minimum number of pairwise transpositions of adjacent items you would have to complete to transform one sequence into 1:n), you can find it in my package, RMallow, available on CRAN. The function is called AllSeqDists. Here is an example:

    library(RMallow)
    # Create a matrix of sequences, each of length 5
    datas <- matrix(c(1:5, 5:1, c(2, 1, 3, 4, 5), c(5, 1, 2, 3, 4), c(1, 2, 4, 5, 6), c(1, 5, 6, 2, 4)), nrow = 6, byrow = TRUE)
    # Calculate all of their Kendall distances to the sequence (1, 2, 3, 4, 5)
    datas <- SimplifySequences(datas)
    dists <- AllSeqDists(datas)
    

    You might also consider Spearman’s metric.
    Also, there are a class of models on ranking data that I must plug called “Mallows models”, depending on what you want to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if there is a better implementation for converting the following VB6
just wondering if there is a way to reduce the amount of code needed
I was just wondering if there is a clean implementation to getting elements before
I'm just wondering if there is a ready implementation of zip-function in the standart
I am wondering if there are any alternatives to the reference implementation of the
I'm wondering if there is an IList<T> implementation that's backed by a hash like
I'm wondering if there exists an implementation of a firefox plugin for OpenJDK, or
I am wondering if there is any concurrent queue implementation/library available in c++?
I was wondering if there is an implementation of SHA-1 hashing in C#, that
I know mutex can be an implementation, however I'm wondering there would be a

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.