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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:21:33+00:00 2026-05-19T03:21:33+00:00

I have a matrix of data (with row names and column names). I would

  • 0

I have a matrix of data (with row names and column names). I would like to do a dotchart of each column of data, with the data sorted from largest to smallest in each chart, and then lay out these plots one atop the other in the figure.

For example, if I had the following matrix:

> X
     W    X    Y     Z
A 11.7  8.7 15.4 100.0
B 18.1 11.7  9.0  13.6
C 10.0 20.3 37.0  19.3
D 41.0 30.9 20.0  35.1
E 66.0  3.0 71.1  50.0

I want to do four dotcharts (columns “W”,”X”,”Y”,”Z”), with the data sorted from largest to smallest for each chart, and the charts laid out on top of one other.

(Note that dotchart(X) won’t work because the sort will be different for each column, see question 4654181)

What’s the sequence of R commands that would allow me to do that?

  • 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-19T03:21:33+00:00Added an answer on May 19, 2026 at 3:21 am
     apply(X, 2, sort)
            W    X    Y     Z
    [1,] 10.0  3.0  9.0  13.6
    [2,] 11.7  8.7 15.4  19.3
    [3,] 18.1 11.7 20.0  35.1
    [4,] 41.0 20.3 37.0  50.0
    [5,] 66.0 30.9 71.1 100.0
    
     dotchart(apply(X, 2, sort))
    

    alt text

    EDIT: To add the labels correctly sorted, you need to use names() on the columns then order()ed by the column values:

    dotchart(apply(X, 2, sort), 
             labels=apply(X, 2, function(x) names(x)[order(x)] )
              )
    

    alt text

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

Sidebar

Related Questions

I have a matrix of data with column and row names, as such: Col1
I have an operation I'd like to run for each row of a data
I have matrix (a) with (1:10),<10 x 1> double. I would like to copy
Is there a way to concatenate the row and column names from an existing
I have a headered matrix and I would like to add the word genes
I have a matrix of data (the columns represent time, and the rows spectrum
I have a matrix of data, m : 12345 12348 2011-05-13 NA 0.18001079 2011-05-16
Suppose I have a matrix of weights, and another matrix of data values. Can
I have a matrix of objects that contains data in this form: name A,2,name
I have a matrix A which I want to convert into a data.frame of

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.