Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 587991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:16:15+00:00 2026-05-13T15:16:15+00:00

How can I view the definition of a S4 function? For instance, I would

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:16:15+00:00Added an answer on May 13, 2026 at 3:16 pm

    S4 classes are relatively complicated, so I would suggest reading this introduction.

    In this case, TSdbi is an example of a generic S4 class that gets extended by all the specific databases packages (e.g. TSMySQL, TSPostgreSQL, etc.). There is nothing more to the TSconnect() method in TSdbi than what you’re seeing: drv=”character”, dbname=”character” are parameters to the function, not functions in and of themselves. If you install some of the specific database packages and use showMethods(“TSconnect”) you will see all the specific instances of that function. If you then call TSconnect() with a specific database driver it will go and use the appropriate function.

    This is how functions such as summary work too. For instance, try calling showMethods(summary). Depending upon which packages are loaded, you should see multiple methods returned

    You can easily see the source code for it on R-Forge: http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/TSdbi/R/TSdbi.R?rev=70&root=tsdbi&view=markup. This is the extent of that function:

    setGeneric("TSconnect", def= function(drv, dbname, ...) standardGeneric("TSconnect"))
    
    setMethod("TSconnect",   signature(drv="character", dbname="character"),
       definition=function(drv, dbname, ...)
                 TSconnect(dbDriver(drv), dbname=dbname, ...))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that can vary significantly, depending on the 'mode' a particular
I know that within a view I can render an action from the same
I know the dotnetkicks.com system is open source so I can view the code
What's the best way for determining whether the user's browser can view PDF files?
How can I view the intermediate translation done to JSP and JSPX pages by
How can I view the SQL code of my query after it has been
In a static view, how can I view an old version of a file?
I have a databound list view and can set all the column widths manually
I wonder if I can test landscape view using simulator?
How can I have a view render a partial (user control) from a different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.