[R] Specifying arguements in user defined functions
chzieg01
chzieg01 at athena.louisville.edu
Wed Nov 19 22:45:31 CET 2003
Dear R subscribees,
First, I am new to R and I apologize if the question is naive. I am trying to
find out where arguments specifications
can be found. For example, the code below (at the very bottom of
this email) contains the argument 'digits' in the function 'lin' which
printout my output to the 3rd decimal place. Somebody showed me the
'digits' argument, but did not show me where to go to find other available
arguments that can be used in functions. (I have emailed this person
but receive an email saying he is out of the office)
To elaborate further, if you look at some of my
code you can see where I specify in the cov(x,y,use="pairwise.complete.obs")
or var(x,use="pairwise.complete.obs"), etc. Now for the arguments in the
'lin' function I would like to specify:
lin <- function (x,y, digits=3, use="all.obs")
or something equivalent that will delete the case if I have NA in either
the x or y variable/vector. (I get the 'use=all.obs' by just typing
'cov' at the R prompt and looking at the function body. I have tried various
combination of the 'use=all.obs' along with what looks to be necessary code
related to it such as "'na.method <- pmatch(use, c("all.obs", "complete.obs",
"pairwise.complete.obs"))'
and .Internal(cov(x, y, na.method)")
My question is where did the 'use=all.obs' argument come from. Is this
basically a function/object/argument(???) that I, a R user, have access to or
did the originator of this function create an object which is compiled within
the cor/cov/var functions, etc? If so, how do I know what function arguments
are available to me or which I have to create. If there are arguments
available to me where do I find them?
I hope this makes sense and appreciate any help you can give me in sending
me on the right path to understand this.
Thanks,
Craig Ziegler
******************************************************************************
lin <- function (x,y, digits=3) # How did the person who knew about
# the digits argument know about
# this argument other than through
# experience
{
lincc <-
(2 * cov(x,y,use="pairwise.complete.obs")) /
(var(x,use="pairwise.complete.obs") +
(var(y,use="pairwise.complete.obs"))+
((mean(x,na.rm=TRUE) - mean(y,na.rm=TRUE))^2))
print(lincc)
etc...
}
More information about the R-help
mailing list