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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:29:05+00:00 2026-05-30T05:29:05+00:00

i have the following data frame dd <- data.frame(b = c(High, Medium, Highest, Low,

  • 0

i have the following data frame

    dd <- data.frame(b = c("High", "Medium", "Highest", "Low", "Not bad","Good", "V. Good"),
   x = c("C3", "C1", "C4", "N2", "C2", "N1","N4"), x = c("5", "2", "3", "6", "7", "5","7") )

so i want the data frame to be transformed using a manual order for the variable X.

for example: that’s the original one

1    High C3   5
2  Medium C1   2
3 Highest C4   3
4     Low N2   6
5 Not bad C2   7
6    Good N1   5
7 V. Good N4   7

but what i want is a new data frame to begin based on the value of X but not alphabetically, but randomly in an order which i chose e.g:

the first row has x=C1, the second have x=C2, the third have x=N4, ...etc

how this can be done??

thank you

  • 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-30T05:29:06+00:00Added an answer on May 30, 2026 at 5:29 am

    Since the x column is a factor,
    you can simply ensure that its levels are in the order you want.

    # New sorting order
    desired_order <- sample(levels(dd$x))
    # Re-order the levels
    dd$x <- factor( as.character(dd$x), levels=desired_order )
    # Re-order the data.frame
    dd <- dd[order(dd$x),]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame with stock data (date, symbol, high, low, open, close,
I have following data to save in database using php my data is :
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have a large data frame with the following fields (example data). #dput(data) gives...
I have a data frame containing the following fields: a, b, c. a and
I have a data.frame with the following characteristics: +-----------------------------------------+ | earning budget ts total
I have the following data frame: > str(df) 'data.frame': 3149 obs. of 9 variables:
Let's say I have the following data frame. dat <- data.frame(city=c(Chelsea,Brent,Bremen,Olathe,Lenexa,Shawnee), tag=c(rep(AlabamaCity,3), rep(KansasCity,3))) I
I have a data frame with columns initially labeled arbitrarily. Later on, I want
I have the following data frame: data.frame(a = c(1,2,3),b = c(1,2,3)) a b 1

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.