[R] reorder always returns "ordered"

Darin A. England england at cs.umn.edu
Wed Oct 6 00:57:54 CEST 2010


Yes Hmisc was loaded. Thanks for the insight. I usually pay
attention to which objects get "masked" ... but reorder was not in
that list. Anyway thanks.
Darin

On Tue, Oct 05, 2010 at 03:50:35PM -0700, Phil Spector wrote:
> Is it possible that the original poster had the Hmisc package loaded?
>
>> Hmisc::reorder.factor
> function (x, v, FUN = mean, ...) ordered(x, levels(x)[order(tapply(v, x, 
> FUN, ...))])
> <environment: namespace:Hmisc>
>
> Without that package, reorder.default gets called:
>> getAnywhere('reorder.default')
> A single object matching ???reorder.default??? was found
> It was found in the following places
>   registered S3 method for reorder from namespace stats
>   namespace:stats
> with value
>
> function (x, X, FUN = mean, ..., order = is.ordered(x)) {
>     scores <- tapply(X, x, FUN, ...)
>     ans <- (if (order)
>         ordered
>     else factor)(x, levels = names(sort(scores)))
>     attr(ans, "scores") <- scores
>     ans
> }
> <environment: namespace:stats>
>
> 					- Phil Spector
> 					 Statistical Computing Facility
> 					 Department of Statistics
> 					 UC Berkeley
> 					 spector at stat.berkeley.edu
>
>
>
> On Tue, 5 Oct 2010, Joshua Wiley wrote:
>
>>> sessionInfo()
>> R version 2.11.1 (2010-05-31)
>> i486-pc-linux-gnu
>>
>>> x <- factor(1:5)
>>> x.ro <- reorder(x, rnorm(5))
>>> is.ordered(x.ro)
>> [1] FALSE
>>> x.ro <- reorder(x, rnorm(5), ordered=FALSE)
>>> is.ordered(x.ro)
>> [1] FALSE
>>
>>
>> On Tue, Oct 5, 2010 at 3:14 PM, Darin A. England <england at cs.umn.edu> wrote:
>>>
>>> Or at least is seems that way to me. It's not a big problem, but the
>>> behavior doesn't match the documentation. (I think r-help is the
>>> place to report this. )
>>>
>>> > x <- factor(1:5)
>>> > x.ro <- reorder(x, rnorm(5))
>>> > is.ordered(x.ro) ??# should be FALSE according to ?reorder
>>> [1] TRUE
>>> >
>>> > x.ro <- reorder(x, rnorm(5), ordered=FALSE)
>>> > is.ordered(x.ro) ??# should be FALSE
>>> [1] TRUE
>>>
>>>
>>> Here is my session info:
>>> > sessionInfo()
>>> R version 2.11.1 (2010-05-31)
>>> x86_64-unknown-linux-gnu
>>>
>>> locale:
>>> ??[1] LC_CTYPE=en_US.UTF-8 ?? ?? ?? LC_NUMERIC=C
>>> ??[3] LC_TIME=en_US.UTF-8 ?? ?? ?? ??LC_COLLATE=en_US.UTF-8
>>> ??[5] LC_MONETARY=C ?? ?? ?? ?? ?? ?? ??LC_MESSAGES=en_US.UTF-8
>>> ??[7] LC_PAPER=en_US.UTF-8 ?? ?? ?? LC_NAME=C
>>> ??[9] LC_ADDRESS=C ?? ?? ?? ?? ?? ?? ?? LC_TELEPHONE=C
>>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] splines ?? datasets ??utils ?? ?? stats ?? ?? graphics ??grDevices
>>> methods
>>> [8] base
>>>
>>> other attached packages:
>>> [1] Design_2.3-0 ?? ??Hmisc_3.8-3 ?? ?? survival_2.35-8 RODBC_1.3-2
>>> [5] MASS_7.3-7 ?? ?? ??lattice_0.19-11
>>>
>>> loaded via a namespace (and not attached):
>>> [1] cluster_1.13.1 grid_2.11.1 ?? ??tools_2.11.1
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list