[Rd] which.max does not work on numeric_version class vectors

Fer |@rcego@p| @end|ng |rom gm@||@com
Mon Dec 22 20:48:43 CET 2025


Are objects of class 'numeric_version' of class 'numeric' ?


I guess that is the problem...


Best

F.

On 12/20/25 16:34, Gabor Grothendieck wrote:
>    versions <- c("9.10", "9.2")
>    nv <- numeric_version(versions)
>    class(nv)
>    ## [1] "numeric_version"
>
>    max(nv) # ok
>    ## [1] ‘9.10’
>
>    versions[tail(order(nv), 1)] # ok
>    ## [1] "9.10"
>
>    sort(nv, decreasing = TRUE)[1] # ok
>    ## [1] ‘9.10’
>
>    versions[which.max(xtfrm(nv))] # ok
>    ## [1] "9.10"
>
>    versions[which.max(nv)] # error
>    ## Error in which.max(nv) : 'list' object cannot be coerced to type 'double'
>
>
	[[alternative HTML version deleted]]



More information about the R-devel mailing list