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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:08:22+00:00 2026-06-13T14:08:22+00:00

Possible Duplicate: Data frame transformation gives different results when same code is run before

  • 0

Possible Duplicate:
Data frame transformation gives different results when same code is run before and after attaching (apparently) unrelated packages

I’m having a bit of a problem. I used to use this method to quickly reorder factors for plotting with ggplot2. But it doesn’t seem to be working:

tmp <- data.frame(Letters=letters[1:26],values=rnorm(26))
tmp <- transform(tmp, Letters = reorder(Letters,values))

identical(levels(tmp$Letters),letters[1:26]) # True! but shouldn't it be reorderd?

What’s going on here?

SessionInfo()

R version 2.15.2 (2012-10-26)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8       
 [4] LC_COLLATE=en_CA.UTF-8     LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] tools     stats     graphics  grDevices utils     methods   base     

other attached packages:
[1] reshape_0.8.4   digest_0.5.2    plyr_1.7.1      ggplot2_0.9.2.1

loaded via a namespace (and not attached):
 [1] brew_1.0-6         colorspace_1.2-0   dichromat_1.2-4    evaluate_0.4.2     grid_2.15.2       
 [6] gtable_0.1.1       gtools_2.7.0       httr_0.2           labeling_0.1       MASS_7.3-22       
[11] memoise_0.1        munsell_0.4        parallel_2.15.2    proto_0.3-9.2      RColorBrewer_1.0-5
[16] RCurl_1.95-1.1     reshape2_1.2.1     scales_0.2.2       stringr_0.6.1      whisker_0.1    
  • 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-06-13T14:08:22+00:00Added an answer on June 13, 2026 at 2:08 pm

    gdata defines a method reorder.factor which has a different behavior that reorder.default applied to factors. See a more detailed discussion in this other question.

    I’ve included a transcript of this behavior, with and without gdata, starting in a new session below; note that once you have loaded gdata, it is very difficult to get rid of that method (for reasons explored here).

    > tmp <- data.frame(Letters=letters[1:26],values=rnorm(26))
    > tmp <- transform(tmp, Letters = reorder(Letters,values))
    > 
    > identical(levels(tmp$Letters),letters[1:26])
    [1] FALSE
    > sessionInfo()
    R version 2.15.2 (2012-10-26)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    
    locale:
    [1] LC_COLLATE=English_United States.1252 
    [2] LC_CTYPE=English_United States.1252   
    [3] LC_MONETARY=English_United States.1252
    [4] LC_NUMERIC=C                          
    [5] LC_TIME=English_United States.1252    
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    > 
    > library("gdata")
    gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
    
    gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
    
    Attaching package: ‘gdata’
    
    The following object(s) are masked from ‘package:stats’:
    
        nobs
    
    The following object(s) are masked from ‘package:utils’:
    
        object.size
    
    > 
    > tmp <- data.frame(Letters=letters[1:26],values=rnorm(26))
    > tmp <- transform(tmp, Letters = reorder(Letters,values))
    > 
    > identical(levels(tmp$Letters),letters[1:26])
    [1] TRUE
    > sessionInfo()
    R version 2.15.2 (2012-10-26)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    
    locale:
    [1] LC_COLLATE=English_United States.1252 
    [2] LC_CTYPE=English_United States.1252   
    [3] LC_MONETARY=English_United States.1252
    [4] LC_NUMERIC=C                          
    [5] LC_TIME=English_United States.1252    
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] gdata_2.12.0
    
    loaded via a namespace (and not attached):
    [1] gtools_2.7.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Counting unique items in data frame Hi my data includes same items
Possible Duplicate: Selecting data from two different servers in SQL Server How can I
Possible Duplicate: Is uninitialized data behavior well specified? I tried the following code #include<stdio.h>
Possible Duplicate: Extracting indices for data frame rows that have MAX value for named
Possible Duplicate: Get column index from label in a data frame I need to
Possible Duplicate: dropping factor levels in a subsetted data frame in R I have
Possible Duplicate: dropping factor levels in a subsetted data frame in R I'm trying
Possible Duplicate: Set NA to 0 in R I have a data.frame with a
Possible Duplicate: It is possible to insert data in two different table in mysql
Possible Duplicate: Read csv with two headers into a data.frame I am new to

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.