Skip to content
Prev 1334 / 1559 Next

dbWriteTable and dbReadTable generics

Not necessarily - you can use the signature argument to setGeneric to
say which arguments can be part of the method signature. Simple
example below:

setGeneric("f", function(x, y, z) standardGeneric("f"))
setMethod("f", signature(z = "numeric"), function(x, y, z) z * 2)

f(,, 2)

setGeneric("g", function(x, y, z) standardGeneric("g"),
  signature = "x")
setMethod("g", signature(z = "numeric"), function(x, y, z) z * 2)
So what do you think of the following? I think it does a better job of
meeting those goals than the current code.

setGeneric("dbWriteTable",
  def = function(conn, name, value, row.names = FALSE,
                       overwrite = FALSE, append = FALSE, ...) {
     standardGeneric("dbWriteTable")
  }, valueClass = "logical", signature = "conn"
)

setGeneric("dbReadTable",
  def = function(conn, name, row.names = FALSE, ...) {
    standardGeneric("dbReadTable")
  },
  valueClass = "data.frame", signature = "conn"
)

Hadley