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
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
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
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
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
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
6 matches
Mail list logo