Try this (provided the comments are actually _in_ the function -- in the example you gave they are not).
> foo <- + function(x){ + # comments line 1 + # comments line 2 + # etc.. + x <- 2 + } > > grep("^#", attr(foo, "source"), value = TRUE) [1] "# comments line 1" "# comments line 2" "# etc.." Also be aware of the keep.source option: ?options On Thu, Aug 14, 2008 at 7:15 PM, A.Ajakh <[EMAIL PROTECTED]> wrote: > Hi All, > > Imagine that we have a function defined as follows: > foo <- > # comments line 1 > # comments line 2 > # etc.. > function(x){ > x <- 2 > } > I can use args(foo) to get the arguments for foo. Is there any function to > get > the comment lines at the beginning of the function? > >From what I understand the prompt() function allows one to create a .Rd file > which > can be compiled but I am not there yet. > On page 31 of "Programming with Data" (J. Chambers) one can read that the > help ? function does what I want but It does not work the same way in R I > guess. > I use R version 2.7.0 on Win XP. > Thank you for your time. > AA. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.