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

Gabor Grothendieck ggrothend|eck @end|ng |rom gm@||@com
Sat Dec 20 16:34:51 CET 2025


  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'


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-devel mailing list