Re: [Rd] Base R: applying min/max functions() to character string vectors (PR#9428)

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri 22 Dec 2006 - 16:08:44 GMT

On 12/22/2006 10:20 AM, xiao.gang.fan1@libertysurf.fr wrote:
> Full_Name: Xiao Gang FAN
> Version: 2.4.0
> OS: Windows XP
> Submission from: (NULL) (159.50.101.9)
>
>
> Dear All,
>
> This is not really a bug report, but rather a change wish to the Base R
> behaviour
> on some functions when applying them to character strings vectors/matrices.
>
> Actually in R, we can do thinks like, the most naturally way in this the world:

>> "a" < "b"

> [1] TRUE
>
>> order(c("b","a"))

> [1] 2 1
>
>> pmax(c("a","b"), c("b"))

> [1] "b" "b"
>
>
> But helas, we can't do things like:
>> max(c("a","b"))

> Error in max(..., na.rm = na.rm) : invalid 'type' (character) of argument
>
>> range(c("z","b","w","c"))

> Error in min(..., na.rm = na.rm) : invalid 'type' (character) of argument
>
>> which.min(c("b","a"))

> integer(0)
> Warning message:
> NAs introduced by coercion
>
> I hope that you could understand the incoherence exhibited here
> and my wish to see that to be changed some day, say in the becoming
> year 2007. Here's a first list of functions to be reviewed:
> min(), max(), which.min(), which.max(), range(), ...

That does seem like a reasonable change. Why not submit a patch? min and max are in https://svn.r-project.org/R/trunk/src/main/summary.c. I haven't looked up the others, but it's possible they just call the internal code for min and max.

Duncan Murdoch



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Dec 23 03:14:41 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Dec 2006 - 17:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.