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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:08:58+00:00 2026-05-16T23:08:58+00:00

I have a melted data.frame, dput(x), below: ## dput(x) x <- structure(list(variable = structure(c(1L,

  • 0

I have a melted data.frame, dput(x), below:

## dput(x)    
x <- structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 
4L, 4L), .Label = c("a", "b", "c", "d"), class = "factor"), 
value = structure(c(1L, 
2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 
6L, 1L, 2L, 3L, 4L, 5L, 6L), .Label = c("Never Heard of", 
"Heard of but Not at all Familiar", 
"Somewhat Familiar", "Familiar", "Very Familiar", "Extremely Familiar"
), class = "factor"), freq = c(10L, 24L, 32L, 90L, 97L, 69L, 
15L, 57L, 79L, 94L, 58L, 19L, 11L, 17L, 34L, 81L, 94L, 85L, 4L, 
28L, 59L, 114L, 82L, 35L)), .Names = c("variable", "value", "freq"
), row.names = c(NA, -24L), class = "data.frame")

Which looks like this (for those of you who don’t need a test set):

   variable                            value freq
1         a                   Never Heard of   10
2         a Heard of but Not at all Familiar   24
3         a                Somewhat Familiar   32
4         a                         Familiar   90
5         a                    Very Familiar   97
6         a               Extremely Familiar   69
7         b                   Never Heard of   15
8         b Heard of but Not at all Familiar   57
9         b                Somewhat Familiar   79
10        b                         Familiar   94
11        b                    Very Familiar   58
12        b               Extremely Familiar   19
13        c                   Never Heard of   11
14        c Heard of but Not at all Familiar   17
15        c                Somewhat Familiar   34
16        c                         Familiar   81
17        c                    Very Familiar   94
18        c               Extremely Familiar   85
19        d                   Never Heard of    4
20        d Heard of but Not at all Familiar   28
21        d                Somewhat Familiar   59
22        d                         Familiar  114
23        d                    Very Familiar   82
24        d               Extremely Familiar   35

Now, I can make a nice and pretty plot akin to this:

ggplot(x, aes(variable, freq, fill = value)) + 
geom_bar(position = "fill") + 
coord_flip() + 
scale_y_continuous("", formatter="percent")

Question

What I would like to do is sort a,b,c,d by the highest to lowest “freq” of “Extremely Familiar”

?relevel and ?reorder haven’t provided any constructive examples for this usage.

Your help, is always appreciated.

Cheers,

BEB

  • 1 1 Answer
  • 1 View
  • 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-16T23:08:59+00:00Added an answer on May 16, 2026 at 11:08 pm

    Here is one way:

    tmpfun <- function(i) {
        tmp <- x[i,]
        -tmp[ tmp$value=='Extremely Familiar', 'freq' ]
    }
    
    x$variable <- reorder( x$variable, 1:nrow(x), tmpfun )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a melted data frame with your standard id, variable and value columns.
Assuming I have a melted data.frame that looks like this: variable value 1 A
I have a semi-melted data frame that looks like this: head(final_melt) Group Source variable
I have a data.frame (which I melted using the melt function), from which I
I have a data frame that follows the below long Pattern: Name MedName Name1
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I often run into an issue where I have a data frame that has
I have a melted dataset containing a column value which represent an absolute number
have written this little class, which generates a UUID every time an object 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.