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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:04:15+00:00 2026-06-13T13:04:15+00:00

Suppose I have a function closure in my package, for example f = function(x)

  • 0

Suppose I have a function closure in my package, for example

f = function(x) {
    x = x
    g = function(y) x <<- y
    h = function() x
    list(g = g, h = h)
}

l = f(5)
l$g(10)
l$h()

What is the correct (in the official CRAN sense) way of documenting this function? In particular,

  1. I would like to use roxygen2
  2. I would like to provide documentation for the functions g and h
  • 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-13T13:04:16+00:00Added an answer on June 13, 2026 at 1:04 pm

    One way would be to do something similar to ?family where you document g() and h() in the Value section of the .Rd file. Then provide extended documentation about g() and h() in a bespoke \section{foo}, which you point to in the Value section entries for the two functions.

    \value{
      Returns an object of class \code{"foo"}, a list with the
      following components:
    
      \item{g}{function; does foo. See Returned Functions for details.}
      \item{h}{function; does bar. See Returned Functions for details.}
    }
    \section{Returned Functions}{
      The returned functions do, blah blah...
    
      \code{g} is defined as
    
      \preformatted{
      g(x, y, z, ...)
      }
    
      Arguments are:
    
      \describe{
        \item{x}{foo}
        \item{y}{foo}
        \item{z}{foo}
      }
    }
    

    Whilst roxygen won’t be able to do this from the argument @param, but you should be able to write this as an arbitrary roxygen section to add to the Rd file. The Value section can be written as standard roxygen markup, only the bespoke section would need to be entered literally.

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

Sidebar

Related Questions

Suppose I have this function, in pseudo-code, that reverse a list: def function reverse(
Suppose I have a function that returns a closure: sub generator { my $resource
Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
Suppose I have a function like this (I use akka 2.0.2): def foo(message: String):
Suppose I have this function: void my_test() { A a1 = A_factory_func(); A a2(A_factory_func());
Suppose I have a function which looks like this: template <class In, class In2>
Suppose I have a garden-variety closure like this bare-bones sample: (let ((alpha 0) #|
Suppose I have some javascript code like this: function Person(){} var pro=Person.prototype; pro[setName]=function(){} pro[setAge]=function(){}
Suppose I have this function: std::string Func1(std::string myString) { //do some string processing std::string
Suppose I have this function signature: def foo(a=True, b=True, c=True, d=True, e=True): I've decided

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.