Làm thế nào tôi có thể xem định nghĩa của hàm S4? Ví dụ, tôi muốn xem định nghĩa của TSconnect trong gói TSdbi. LệnhKiểm tra phương pháp S4
showMethods("TSconnect")
cho thấy rằng, trong số những hàm khác, hàm cho drv = "histQuoteDriver", dbname = "character".
Tôi làm cách nào để xem định nghĩa của hàm này? Nếu nó là một hàm S3, sẽ chỉ có đối số đầu tiên có thể xác định được (drv), có thể được kiểm tra bằng print (TSconnect.histQuoteDriver).
Sửa: Từ r-rèn tôi phát hiện ra đầu ra mong muốn:
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)
})
Có cách nào để tra nghĩa này từ bên trong một phiên R?
Bạn có thể tìm thấy http://stevencarlislewalker.wordpress.com/s3-s4-dictionary/ hữu ích. –