Re: [R] Documenting a function: How to get the comments in a function similar to args()

2008-08-21 Thread AAR
Thanks to everyone who responded. It was all very helpful. AA. A.Ajakh 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

Re: [R] Documenting a function: How to get the comments in a function similar to args()

2008-08-15 Thread Carl Witthoft
Along the lines of Gabor's method, presumably you could put a "spare" argument in your function: foo<- function(x,help=FALSE,...) { helpout<-c(comment, comment, end of comments) if(something_is_wrong_with_inputs || help=TRUE) { print(helpout) stop #or trycatch, or whatev

Re: [R] Documenting a function: How to get the comments in a function similar to args()

2008-08-14 Thread stephen sefick
sorry I see what you mean- Gabor has the answer. On Thu, Aug 14, 2008 at 8:22 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > What are the comments line at the beginning of the function? if you > just type in the function name then you get the code, and it seems > that R removes the comment lines

Re: [R] Documenting a function: How to get the comments in a function similar to args()

2008-08-14 Thread Gabor Grothendieck
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.." A

Re: [R] Documenting a function: How to get the comments in a function similar to args()

2008-08-14 Thread stephen sefick
What are the comments line at the beginning of the function? if you just type in the function name then you get the code, and it seems that R removes the comment lines to make the code more readable. I just looked at a function in a package that I created and know that there are comments in there

[R] Documenting a function: How to get the comments in a function similar to args()

2008-08-14 Thread A.Ajakh
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 prom