Skip to content

Make all methods S3-methods, for easier integration with other packages e.g. disk.frame #9

@xiaodaigh

Description

@xiaodaigh

I want to support tidyfast's verbs with disk.frame but I would need the verbs to be S3-compatible.

E.g. your code would beccome

dt_count <- function(dt, ....) {
   UseMethod("dt_count")
}

dt_count.default <- function(dt_, ..., na.rm = FALSE, wt = NULL){

  if (isFALSE(is.data.table(dt_)))
    .dt <- as.data.table(dt_)

  dots <- substitute(list(...))
  wt <- substitute(wt)

  if (na.rm)
    dt_ <- dt_[complete.cases(dt_)]

  if (!is.null(wt))
    return(dt_[, list(N = sum(eval(wt))), keyby = eval(dots)])

  dt_[, .N, keyby = eval(dots)]
}

So in disk.frame, I would implement

dt_count.disk.frame(dt, ...) {
...
}

That way, we can enable tidyfast verbs to be used with large on-disk datasets :)

Relevant issue: DiskFrame/disk.frame#218

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions