[Rd] Time to add is.formula() to 'stats'?

Mikael Jagan j@g@nmn2 @end|ng |rom gm@||@com
Sat Apr 8 02:26:16 CEST 2023


I know that it has been discussed in the past, but I wanted to ask
to revisit the idea of exporting

    is.formula <- function(x) inherits(x, "formula")

from 'stats', parallel to is.data.frame() in 'base', given how
widely formulae are used these days in conjunction with data frames,
even outside of model fitting functions (e.g., for split-apply).

One could argue that today data frames and formulae go hand in hand,
and that the lack of is.formula() is a rather ugly asymmetry ...

Furthermore, 'formula' is one of the only S3 classes generated by way
of a primitive (the `~` operator, calling do_tilde() in names.c), so
it is really in some sense "special" { compared to 'factor', 'POSIXlt',
etc. }.

What do people think?

In case it helps, I've gathered some data from 'base' and the so-called
'defaultPackages', reproduced by the attached R script ... see below.

Mikael


----------------------------


1. For which X does is.X() have no corresponding as.X()?

  [1] "R"         "atomic"    "element"   "finite"    "hashtab"   "infinite"
  [7] "language"  "leaf"      "loaded"    "mts"       "na"        "nan"
[13] "object"    "primitive" "recursive" "tskernel"  "unsorted"

2. For which Y does as.Y() have no corresponding is.Y()?

  [1] "Date"          "POSIXct"       "POSIXlt"       "dendrogram"
  [5] "difftime"      "dist"          "formula"       "graphicsAnnot"
  [9] "hclust"        "hexmode"       "octmode"       "person"
[13] "personList"    "roman"

3. For which Z does is.Z() just call inherits(., "Z")?

[1] "data.frame"      "factor"          "numeric_version" "ordered"
[5] "package_version" "raster"          "relistable"      "table"

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: as.is.R
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20230407/d14c0775/attachment.ksh>


More information about the R-devel mailing list