Re: AW: AW: [R] constructing specially ordered factor

2004-10-05 Thread Thomas Lumley
On Tue, 5 Oct 2004, Khamenia, Valery wrote: BTW, do you mean that current hash-based implementation brings *clearly* better performance than any O(n*log(n)) sort based algorithm? If I have correctly understood src/main/unique.c then current hash function is niether minimal perfect hash function nor

AW: AW: [R] constructing specially ordered factor

2004-10-05 Thread Khamenia, Valery
> Please follow the posting guide and do your homework before > posting, 1. my last homework in university was done a lot of years ago. 2. I always try to follow posting guide. > An object of the same type of 'x'. but if an element is equal to > one with a smaller index, it is remov

Re: AW: [R] constructing specially ordered factor

2004-10-04 Thread Petr Pikal
On 4 Oct 2004 at 15:27, Khamenia, Valery wrote: > Hi Petr, > > Thank you for your reply. > > > Factor <- function(f,n, decreasing=TRUE, ...) { > > ooo<-order(levels(factor(n)), decreasing=decreasing) > > my.order<-levels(factor(f))[ooo] > > factor(f, levels=my.order) > > } > > it works incorr

Re: AW: [R] constructing specially ordered factor

2004-10-04 Thread Prof Brian Ripley
On Mon, 4 Oct 2004, Khamenia, Valery wrote: > Hi Dimitris, > > thank you for your reply, > > > does the following work in your data: > > > > levs <- unique.default(Names) > > factor(Names, levs[order(unique.default(Weights))]) > > your solution is really shorter, but has two issues to be > m

AW: [R] constructing specially ordered factor

2004-10-04 Thread Khamenia, Valery
Hi Petr, Thank you for your reply. > Factor <- function(f,n, decreasing=TRUE, ...) { > ooo<-order(levels(factor(n)), decreasing=decreasing) > my.order<-levels(factor(f))[ooo] > factor(f, levels=my.order) > } it works incorrectly. Indeed, let's apply with your Factor: unames <- c("thousands",

AW: [R] constructing specially ordered factor

2004-10-04 Thread Khamenia, Valery
Hi Dimitris, thank you for your reply, > does the following work in your data: > > levs <- unique.default(Names) > factor(Names, levs[order(unique.default(Weights))]) your solution is really shorter, but has two issues to be meant here: 1. "unique.default" is applied twice, what might be

Re: [R] constructing specially ordered factor

2004-10-04 Thread Petr Pikal
On 4 Oct 2004 at 12:01, Khamenia, Valery wrote: > Hi all, > > my colleagues deal with tables, where every factor is > represented in two columns. The first column contains some > numeric codes and the second contains the corresponding > symbolic name. For example: > > ISEX SSEX > 0 Fem

Re: [R] constructing specially ordered factor

2004-10-04 Thread Dimitris Rizopoulos
nday, October 04, 2004 12:01 PM Subject: [R] constructing specially ordered factor Hi all, my colleagues deal with tables, where every factor is represented in two columns. The first column contains some numeric codes and the second contains the corresponding symbolic name. For example: ISEX SSEX 0

[R] constructing specially ordered factor

2004-10-04 Thread Khamenia, Valery
Hi all, my colleagues deal with tables, where every factor is represented in two columns. The first column contains some numeric codes and the second contains the corresponding symbolic name. For example: ISEXSSEX 0 Female 1 Male 0 Female 0 Female ... another examp