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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:48:16+00:00 2026-05-17T22:48:16+00:00

I have a data frame with 900,000 rows and 11 columns in R. The

  • 0

I have a data frame with 900,000 rows and 11 columns in R. The column names and types are as follows:

column name: date / mcode / mname / ycode / yname / yissue  / bsent   / breturn / tsent   / treturn / csales
type:        Date / Char  / Char  / Char  / Char  / Numeric / Numeric / Numeric / Numeric / Numeric / Numeric

I want to sort the data by those variables in the following order:

  1. date
  2. mcode
  3. ycode
  4. yissue

The order of levels are important here, i.e. they should be sorted by date first, and if there are identical dates, they should be sorted by mcode, so and so forth. How can I do that in R?

  • 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-17T22:48:16+00:00Added an answer on May 17, 2026 at 10:48 pm

    Perhaps something like this?

    > df<- data.frame(a=rev(1:10), b=rep(c(2,1),5), c=rnorm(10))
    > df
        a b           c
    1  10 2 -0.85212079
    2   9 1 -0.46199463
    3   8 2 -1.52374565
    4   7 1  0.28904717
    5   6 2 -0.91609012
    6   5 1  1.60448783
    7   4 2  0.51249796
    8   3 1 -1.35119089
    9   2 2 -0.55497745
    10  1 1 -0.05723538
    > with(df, df[order(a, b, c), ])
        a b           c
    10  1 1 -0.05723538
    9   2 2 -0.55497745
    8   3 1 -1.35119089
    7   4 2  0.51249796
    6   5 1  1.60448783
    5   6 2 -0.91609012
    4   7 1  0.28904717
    3   8 2 -1.52374565
    2   9 1 -0.46199463
    1  10 2 -0.85212079
    

    The “order” function can take several vectors as arguments.

    • 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 named d of ~1,300,000 lines and 4 columns and another
Suppose I have a data frame with a column for values and another column
I have data that looks like this: entities id name 1 Apple 2 Orange
If I have data like this: Key Name 1 Dan 2 Tom 3 Jon
Lets say I have a data frame with two variables x & y and
Dear all, I have a data frame which comes directly from a sensor. The
Suppose I have the following data.frame : foo <- data.frame(ocean=c('Atlantic', 'Pacific'), city=c('Boston', 'San Francisco'),
I have data in a MySQL database. I am sending the user a URL
I have data coming from the database in the form of a DataSet .
I have data that looks like CUSTOMER, CUSTOMER_ID, PRODUCT ABC INC 1 XYX ABC

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.