如何查看S4功能的定义?例如,我想在封装TSdbi中看到TSconnect的定义。命令
showMethods("TSconnect")
揭示除了其他之外,还有drv =“histQuoteDriver”,dbname =“character”的函数。
我怎样才能看到这个函数的定义?如果它是S3函数,则只有第一个可定义的参数(drv),可以使用print(TSconnect.histQuoteDriver)进行检查。
编辑:从r-forge我发现了所需的输出:
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 )
} )
有没有办法从R会话中获取此定义?