title: R List functions in file
body: <p>How do I list all functions of a certain R file doing something like</p>
  
  <pre><code>list = list.all.functions(file.name, alphabetical = TRUE, ...)
  </code></pre>
  
  <p>where <code>list</code> is a string vector containing the names of the functions in <code>file.name</code>?</p>
  
  <p>The solution of <a href="https://stackoverflow.com/questions/20259681/how-to-list-all-the-functions-and-their-arguments-in-an-r-file/20260081#20260081">How to list all the functions and their arguments in an R file?</a> gives no output for me (since I am not interested in arguments I opened a new question).</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>File <code>allometry.R</code> starts with </p>
  
  <pre><code>#==========================================================================================#
  #==========================================================================================#
  #    Standing volume of a tree.                                                            #
  #------------------------------------------------------------------------------------------#
  dbh2vol &lt;&lt;- function(hgt,dbh,ipft){
     vol  = pft$b1Vol[ipft] * hgt * dbh ^ pft$b2Vol[ipft]
     return(vol)
  }#end function dbh2ca
  #==========================================================================================#
  #==========================================================================================#
  </code></pre>
  
  <p>My main looks like </p>
  
  <pre><code>rm(list=ls())
  
  here     = "/directory/of/allometry.R/"
  setwd(here)
  
  is_function = function (expr) {
    if (! is_assign(expr))
      return(FALSE)
    value = expr[[3]]
    is.call(value) &amp;&amp; as.character(value[[1]]) == 'function'
  }
  
  function_name = function (expr)
    as.character(expr[[2]])
  
  is_assign = function (expr)
    is.call(expr) &amp;&amp; as.character(expr[[1]]) %in% c('=', '&lt;-', 'assign')
  
  
  file_parsed = parse("allometry.R")
  functions = Filter(is_function, file_parsed)
  function_names = unlist(Map(function_name, functions))
  </code></pre>