How can I view the definition of a S4 function? For instance, I would like to see the definition of TSconnect in package TSdbi. The command
showMethods("TSconnect")
reveals that there is, among others, a function for drv="histQuoteDriver", dbname="character".
How can I see the definition of this function? If it were a S3 function, there would be only the first argument definable (drv), which could be inspected with print(TSconnect.histQuoteDriver).
Edit: From r-forge I found out the desired output:
setMethod("TSconnect", signature(drv="histQuoteDriver", dbname="character"),
definition= function(drv, dbname, user="", password="", host="", ...){
# user / password / host for future consideration
if (is.null(dbname)) stop("dbname must be specified")
if (dbname == "yahoo") {
con <- try(url("http://quote.yahoo.com"), silent = TRUE)
if(inherits(con, "try-error"))
stop("Could not establish TShistQuoteConnection to ", dbname)
close(con)
}
else if (dbname == "oanda") {
con <- try(url("http://www.oanda.com"), silent = TRUE)
if(inherits(con, "try-error"))
stop("Could not establish TShistQuoteConnection to ", dbname)
close(con)
}
else
warning(dbname, "not recognized. Connection assumed working, but not tested.")
new("TShistQuoteConnection", drv="histQuote", dbname=dbname, hasVintages=FALSE, hasPanels=FALSE,
user = user, password = password, host = host )
} )
Is there a way to get this definition from within an R session?