[R-gregmisc-users] SF.net SVN: r-gregmisc:[1932] trunk/gdata
Brought to you by:
warnes
From: <wa...@us...> - 2015-04-22 22:32:08
|
Revision: 1932 http://sourceforge.net/p/r-gregmisc/code/1932 Author: warnes Date: 2015-04-22 22:32:01 +0000 (Wed, 22 Apr 2015) Log Message: ----------- Correct behavior of reorder.factor() when argument 'X' is supplied by delgating to stats:::reorder.default() Modified Paths: -------------- trunk/gdata/R/reorder.R Added Paths: ----------- trunk/gdata/tests/test.reorder.factor.R trunk/gdata/tests/test.reorder.factor.Rout.save Modified: trunk/gdata/R/reorder.R =================================================================== --- trunk/gdata/R/reorder.R 2015-04-22 21:35:19 UTC (rev 1931) +++ trunk/gdata/R/reorder.R 2015-04-22 22:32:01 UTC (rev 1932) @@ -12,6 +12,9 @@ { constructor <- if (order) ordered else factor + if(!missing(X)) + return( NextMethod(x)) + if (!missing(new.order)) { if (is.numeric(new.order)) Added: trunk/gdata/tests/test.reorder.factor.R =================================================================== --- trunk/gdata/tests/test.reorder.factor.R (rev 0) +++ trunk/gdata/tests/test.reorder.factor.R 2015-04-22 22:32:01 UTC (rev 1932) @@ -0,0 +1,11 @@ +## Test results before and after loading gdata + +m <- factor(c('a','b','c')) + +( m1 <- reorder(m, X=c(3, 2, 1)) ) + +library(gdata) + +( m2 <- reorder(m, X=c(3, 2, 1)) ) + +stopifnot(identical(m1,m2)) Added: trunk/gdata/tests/test.reorder.factor.Rout.save =================================================================== --- trunk/gdata/tests/test.reorder.factor.Rout.save (rev 0) +++ trunk/gdata/tests/test.reorder.factor.Rout.save 2015-04-22 22:32:01 UTC (rev 1932) @@ -0,0 +1,60 @@ + +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +Copyright (C) 2014 The R Foundation for Statistical Computing +Platform: x86_64-unknown-linux-gnu (64-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + + Natural language support but running in an English locale + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> ## Test results before and after loading gdata +> +> m <- factor(c('a','b','c')) +> +> ( m1 <- reorder(m, X=c(3, 2, 1)) ) +[1] a b c +attr(,"scores") +a b c +3 2 1 +Levels: c b a +> +> 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 is masked from ‘package:stats’: + + nobs + +The following object is masked from ‘package:utils’: + + object.size + +Warning message: +S3 methods ‘print.object_size’, ‘c.object_size’ were declared in NAMESPACE but not found +> +> ( m2 <- reorder(m, X=c(3, 2, 1)) ) +[1] a b c +attr(,"scores") +a b c +3 2 1 +Levels: c b a +> +> stopifnot(identical(m1,m2)) +> +> proc.time() + user system elapsed + 0.512 0.070 0.638 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |