2

I have a theory that the function RPostgreSQL::dbWritetable converts POSIXctdates to character before writing them. I am trying to see the source code to confirm this, and despite looking at the following links I am unable to find it. In fact, I do not even know whether what I am looking at is an S3 or S4 method:

show source code for function in R

How can I view the source code for a function?

How do I show the source code of an S4 function in a package?

Firstly, I have the results of RPostgreSQL::dbWriteTable:

nonstandardGenericFunction for "dbWriteTable" defined from package "DBI"
  defined with value class: "logical"

function (conn, name, value, ...) 
{
    ans <- {
        standardGeneric("dbWriteTable")
    }
    .valueClassTest(ans, "logical", "dbWriteTable")
}
<environment: 0x00000000122305e8>
Methods may be defined for arguments: conn, name, value
Use  showMethods("dbWriteTable")  for currently available ones.

The next step seems straightfoward:

> showMethods("dbWriteTable")
Function: dbWriteTable (package DBI)
conn="PostgreSQLConnection", name="character", value="character"
conn="PostgreSQLConnection", name="character", value="data.frame"

This doesn't give me any clues on what to do further. Running getAnwhere:

> getAnywhere("dbWriteTable")
A single object matching ‘dbWriteTable’ was found
It was found in the following places
  package:RPostgreSQL
  package:DBI
  namespace:DBI
with value

function (conn, name, value, ...) 
{
    ans <- {
        standardGeneric("dbWriteTable")
    }
    .valueClassTest(ans, "logical", "dbWriteTable")
}
<environment: 0x00000000122305e8>
attr(,"generic")
[1] "dbWriteTable"
attr(,"generic")attr(,"package")
[1] "DBI"
attr(,"package")
[1] "DBI"
attr(,"group")
list()
attr(,"valueClass")
[1] "logical"
attr(,"signature")
[1] "conn"  "name"  "value"
attr(,"default")
`\001NULL\001`
attr(,"skeleton")
(function (conn, name, value, ...) 
stop("invalid call in method dispatch to 'dbWriteTable' (no default method)", 
    domain = NA))(conn, name, value, ...)
attr(,"class")
[1] "nonstandardGenericFunction"
attr(,"class")attr(,"package")
[1] "methods"

But as there is no object = ... output I have no idea how to use getMethod.

Community
  • 1
  • 1
Alex
  • 15,186
  • 15
  • 73
  • 127
  • 1
    `getMethod("dbWriteTable",signature = c("PostgreSQLConnection", "character", "data.frame"))` [from another link](http://stackoverflow.com/questions/12679941/show-source-code-for-a-function-in-a-package-in-r) – user20650 Oct 26 '16 at 00:13
  • 1
    thanks, that is it! – Alex Oct 26 '16 at 00:20
  • Embarassingly I did not read this answer: http://stackoverflow.com/a/19226817/2109289 properly. The relevant part is the bit that starts with: "There are also methods with more complex signatures for each method, for example" – Alex Oct 26 '16 at 00:28

0 Answers0