r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
282 stars 65 forks source link

minor documentation inaccuracies #1926

Open khusmann opened 3 months ago

khusmann commented 3 months ago

Thanks again for this awesome library! I can tell y'all really value your docs, so I wanted to relay some minor (afaikt) inaccuracies I found in the documentation while learning the library that caused me brief confusions:


  1. This should be vec_proxy_equal(), not vec_proxy() right?

' * ==, !=, unique(), anyDuplicated(), and is.na() use

' [vec_proxy()].

https://github.com/r-lib/vctrs/blob/8bf5ba59bae73705f460ef326b725023cff46efa/R/type-vctr.R#L39C1-L40C20


  1. For bare a vctrs_vctr, quantile() and median() are not implemented.

' * <, <=, >=, >, min(), max(), range(), median(),

' quantile(), and xtfrm() methods use [vec_proxy_compare()].

https://github.com/r-lib/vctrs/blob/8bf5ba59bae73705f460ef326b725023cff46efa/R/type-vctr.R#L42C1-L43C68


  1. vctrs doesn't provide a vec_arith.double() or vec_arith.integer() S3 generic... it actually only provides vec_arith.numeric() and vec_arith.logical()

vctrs provides the hybrid S3 generics/methods for most of the base R types, like vec_arith.integer(). If you don't fully import vctrs with @import vctrs, then you will need to explicitly import the generic you are registering double dispatch methods for with @importFrom vctrs vec_arith.integer.

https://github.com/r-lib/vctrs/blob/8bf5ba59bae73705f460ef326b725023cff46efa/vignettes/s3-vector.Rmd#L1317C1-L1319C1


  1. The documentation for vec_slice() says it will slice the proxy (if available) and then vec_restore(). But in type-rcrd.R there's this definition:
`[[.vctrs_rcrd` <- function(x, i, ...) {
  out <- vec_slice(vec_data(x), i)
  vec_restore(out, x)
}

Does that mean the calls to vec_data() and vec_restore() are technically unnecessary here? Or is there some other magic I'm missing that makes it necessary?