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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:32:41+00:00 2026-05-27T11:32:41+00:00

Forgive my ignorance, but I’m having trouble with sorting a data frame. I would

  • 0

Forgive my ignorance, but I’m having trouble with sorting a data frame. I would like to specify an ordered list like c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") when sorting such that the dataframe is sorted in the order of the list.

In this example, I would like to start with

    Day Present Count
    Fri No  164
    Fri Yes 131
    Mon No  142
    Mon Yes 174
    Sat No  39
    Sat Yes 26
    Sun No  44
    Sun Yes 39
    Thu No  191
    Thu Yes 192
    Tue No  184
    Tue Yes 214
    Wed No  343
    Wed Yes 255

And end with

    Day Present Count
    Mon No  142
    Mon Yes 174
    Tue No  184
    Tue Yes 214
    Wed No  343
    Wed Yes 255
    Thu No  191
    Thu Yes 192
    Fri No  164
    Fri Yes 131
    Sat No  39
    Sat Yes 26
    Sun No  44
    Sun Yes 39

I’ve tried perday[do.call(order, perday[c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")]),] but I get “undefined columns selected”. I get the same error if there are 14 entries in the character vector too, so I’m really confused at this point.

Here’s the dput:

perday<-structure(list(dayofweek = c("Fri", "Fri", "Mon", "Mon", "Sat", 
"Sat", "Sun", "Sun", "Thu", "Thu", "Tue", "Tue", "Wed", "Wed"
), Attended = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L), .Label = c("No", "Yes"), class = "factor"), 
    nrow = c(164L, 131L, 142L, 174L, 39L, 26L, 44L, 39L, 191L, 
    192L, 184L, 214L, 343L, 255L)), .Names = c("dayofweek", "Attended", 
"nrow"), row.names = c(NA, -14L), class = "data.frame")
  • 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-27T11:32:42+00:00Added an answer on May 27, 2026 at 11:32 am

    You can do it “inline” with

    perday[order(factor(perday$dayofweek,levels=c(c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")))),]
    

    which gives

       dayofweek Attended nrow
    3        Mon       No  142
    4        Mon      Yes  174
    11       Tue       No  184
    12       Tue      Yes  214
    13       Wed       No  343
    14       Wed      Yes  255
    9        Thu       No  191
    10       Thu      Yes  192
    1        Fri       No  164
    2        Fri      Yes  131
    5        Sat       No   39
    6        Sat      Yes   26
    7        Sun       No   44
    8        Sun      Yes   39
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive any ignorance of C++ type deduction in this, but I'd like to be
Please forgive my ignorance. Traditionally I've been doing something like this, but it feels
Forgive my ignorance in asking this basic question but I've become so used to
Forgive my ignorance, but I am somewhat new to shell scripting and the use
forgive my ignorance, I thought it was going to be a no-brainer but I
You'll have to forgive my ignorance, but I'm not used to using wide character
Please forgive my ignorance and poor SQL programming skills but I am normally a
This might seem like a dump question, but my complete ignorance with VbScript is
Forgive my ignorance, but I am a beginner in java that comes from using
Please forgive the ignorance, but I'm very new to PHP and I couldn't find

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.