Hi John,
What happens is that you have passed two named arguments to your function
"myfun" along with the matrix "data". Because these arguments have
associated values ("delta", "SE"), these values are substituted into the
expression like this:
x["delta"]/x["SE"]
which is the return value of "myf
> I can't understand how the body of the function, x[c1]/x[c2] refers to
the columns "data" and "SE" of the matrix data.
If you put the line 'str(x)' at the start of myfun(), as in
myfun <- function(x, c1, c2) {
str(x)
x[c1]/x[c2]
}
you would start to see why it works - extractin
Colleagues,
I am trying to understand the syntax of a function passed to apply. The code
below generates a matrix, and passes the matrix to a function that is called by
apply. I don't understand the syntax of the function. In some way the function
computes data[,"delta"]/data[,"SE"]. I can't und
3 matches
Mail list logo