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 8688935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:30:27+00:00 2026-06-12T23:30:27+00:00

Once I defined a class I wonder where to out in a package. Should

  • 0

Once I defined a class I wonder where to out in a package. Should just create a file classDefintions.R containing my S4 class definition and put it to the R folder? If so, how can I document it properly? Is there a .rd file template for S4 classes around?

I found this post on Roxygen2 but I might be a few step behind here. How is it basically done and located?

  • 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-06-12T23:30:28+00:00Added an answer on June 12, 2026 at 11:30 pm

    Just like other R objects, S4 class and method definitions are documented with *.Rd files stored in the man subdirectory of the package source.

    Besides reading the relevant section of R-exts, I’d suggest downloading and looking at the source of a well-written S4-based package with which you’re familiar. (For me that would likely be sp, lme4 or Matrix.)

    Finally, the methods package includes two nifty utility functions, promptClass() and promptMethods() that will fill out a skeleton *.Rd file for any S4 class or method defined in the current R session.

    As an example that uses R objects defined in the sp package, you could do this:

    library(sp)     ## for some example S4 classes and methods
    
    promptClass("SpatialPolygons")
    # A shell of class documentation has been written to the file
    # ‘SpatialPolygons-class.Rd’.
    
    promptMethods("bbox")
    # A shell of methods documentation has been written to the file
    # ‘bbox-methods.Rd’.
    

    And then take a look at the files SpatialPolygons-class.Rd and bbox-methods.Rd to see how much work those functions will save you!


    Edit: After a quick reread of your question, I see you were also asking about how to include the methods and classes themselves. My advice for that’s basically the same: read the manual and “use the source” (making sure to also look at how exportClasses() and exportMethods() directives in the NAMESPACE file are used to export S4 objects.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to iterate over every class defined on my html page once. I
I have defined onbeforeprint and I modify my html code and now once I
Once again, lists are boggling my mind. <div id=headbottom> <ul id=headnavbutton> <li id=button1 class=headnavbutton></li>
I have defined a class with multiple constructors so that the underlying interfaces are
I have defined a class that does a lengthy task and I call it
I'm trying create an immutable object and initialise it from xml config file in
I'm not sure what I'm doing wrong, I thought everything is defined exactly once
I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract
I defined such simple class as below: >>> class myclass(object): name = google And
I implemented a System.Web.IHttpAsyncHandler to limit website bandwidth usage for files download. Once defined

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.