rch 2009 10:14 AM
To: Stavros Macrakis
Cc: r-help@r-project.org; Ben Bolker
Subject: Re: [R] Sorting problem
That's leading to another question: How does rank() work?
If I have a character vector
a<- c("2a", "2c", "3", "5" , "2b" ,"4a
That's leading to another question: How does rank() work?
If I have a character vector
a<- c("2a", "2c", "3", "5" , "2b" ,"4a", "4b")
Then a[order(a)] returns
"2a" "2b" "2c" "3" "4a" "4b" "5", which makes sense
But a[rank(a)] returns
"2a" "3" "5" "4b" "2c" "2b" "4a", which does not seem to m
On Sun, Mar 29, 2009 at 5:21 PM, Ben Bolker wrote:
> Adding
>
> xtfrm.numeric <- function(x) {x}
>
> would seem to add the case that people are looking for -- unless
> there's something special that needs to be handled with NAs ???
Yes, that was what I was suggesting. xtfrm currently converts N
Duncan Murdoch-2 wrote:
>
> On 29/03/2009 2:14 PM, Stavros Macrakis wrote:
>> On Sun, Mar 29, 2009 at 6:15 AM, Duncan Murdoch
>> wrote:
>>> On 28/03/2009 4:57 PM, Stavros Macrakis wrote:
On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch
wrote:
1) Where does the name 'xtfrm' come
On 29/03/2009 2:14 PM, Stavros Macrakis wrote:
On Sun, Mar 29, 2009 at 6:15 AM, Duncan Murdoch wrote:
On 28/03/2009 4:57 PM, Stavros Macrakis wrote:
On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch
wrote:
1) Where does the name 'xtfrm' come from?
I don't know.
Hmm. If the origins of the na
On Sun, Mar 29, 2009 at 6:15 AM, Duncan Murdoch wrote:
> On 28/03/2009 4:57 PM, Stavros Macrakis wrote:
>> On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch
>> wrote:
>> 1) Where does the name 'xtfrm' come from?
> I don't know.
Hmm. If the origins of the name are lost in the mists of history,
per
On 28/03/2009 4:57 PM, Stavros Macrakis wrote:
On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch wrote:
...More generally, the xtfrm() function converts a vector into a numeric one
that sorts in the same order. ...
Thanks, I learn a lot just by reading the answers to other people's
questions o
Stavros Macrakis wrote:
> On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch wrote:
>
>> ...More generally, the xtfrm() function converts a vector into a numeric one
>> that sorts in the same order. ...
>>
>
> Thanks, I learn a lot just by reading the answers to other people's
> questions on
On Sat, Mar 28, 2009 at 7:53 AM, Duncan Murdoch wrote:
> ...More generally, the xtfrm() function converts a vector into a numeric one
> that sorts in the same order. ...
Thanks, I learn a lot just by reading the answers to other people's
questions on this list.
Some followup questions:
1) Wher
Hi, Bill,
Thank you for your reply. The -as.numeric() does not work as I expected.
BA[2] is character with elements like 2A, 2B, 2C, 3, 4A, 4B, 5. I want it to
be sorted as 5, 4B, 4A, 3, 2C, 2B, 2A. The -as.numeric() method produces 5,
3, 2A, 2B, 2C, 4A, 4B.
xtrfm() suggested by Duncan works very
bill.venab...@csiro.au wrote:
Perhaps BA[, 2] is a factor? What you might need is something like
BA[order(BA[, 1], -as.numeric(BA[, 2]), ]
More generally, the xtfrm() function converts a vector into a numeric
one that sorts in the same order. It will work on character columns as
well:
Perhaps BA[, 2] is a factor? What you might need is something like
BA[order(BA[, 1], -as.numeric(BA[, 2]), ]
?
Bill Venables.
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of
Jun Shen [jun.shen...@gmail.com]
Sent: 28 March
Sorry for the last post. I didn't use the latest version of R. It
works under Linux as well for R-2.8.0 patch.
Best
On Thu, Dec 11, 2008 at 11:34 PM, ronggui <[EMAIL PROTECTED]> wrote:
> Sys.setlocale(,"C")
> x1 <- as.character(date()) # I use date to record the time, and save
> it to sqlite data
13 matches
Mail list logo