I'd like to propose some generics for tbl_Andromeda objects, mostly for QoL. For TreatmentPatterns I find myself wanting to get the nrows of a (filtered) table quite often. Currently tbl_Andromeda tables will give back NA when nrow(andromeda$iris) is called.
I currently do this:
library(Andromeda)
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(dplyr)
a <- andromeda()
a$iris <- iris
a$iris %>%
summarise(n = n()) %>%
pull(n)
#> [1] 150
I setup some examples as to what generics we could override for andromeda tables:
nrow()
a$iris <- iris
nrow(a$iris)
#> [1] NA
# nrow is not a generic by default
nrow <- function(x) {
UseMethod("nrow")
}
nrow.tbl_Andromeda <- function(x) {
x %>%
summarise(n = n()) %>%
pull(n)
}
nrow(a$iris)
#> [1] 150
I'd like to propose some generics for
tbl_Andromeda
objects, mostly for QoL. For TreatmentPatterns I find myself wanting to get the nrows of a (filtered) table quite often. Currentlytbl_Andromeda
tables will give backNA
whennrow(andromeda$iris)
is called.I currently do this:
I setup some examples as to what generics we could override for andromeda tables:
nrow()
length()
str()
`[`()
This one is probably overkill
There are probably more generics that would be useful.