Dear all,
I am wondering if there is a way to find how R defined(or wrote) the function of
"coxph"? I don not mean the one that we get by checking help(coxph), but the one
like coxph<-function(....){...}
Thanks,
Jia
To find how R defined the function of "coxph"?
4 messages · Li, Jia, Sundar Dorai-Raj, Zhen Pang +1 more
Li, Jia wrote:
Dear all,
I am wondering if there is a way to find how R defined(or wrote) the function of
"coxph"? I don not mean the one that we get by checking help(coxph), but the one
like coxph<-function(....){...}
Thanks,
Jia
At the commandline, type the following: library(survival) coxph BTW, I'm assuming you are referring to the coxph in the survival package. Please be more specific next time. Better yet, read the posting guide. --sundar
Dear all, I'd like to define a k by k matrix where the element is defined by mn<-function(m,n) sum(choose(m,(m-0:m))*choose((k-m),(n-m+0:m))) the mn function works fine for scalar m and n, however, it fails to define the matrix by outer. a<-outer(1:k,1:k,mn) gives error message: Error in outer(1:k, 1:k, mn) : dim<- : dims [product 64] do not match the length of object [1] In addition: Warning messages: 1: Numerical expression has 64 elements: only the first used in: 0:m 2: Numerical expression has 64 elements: only the first used in: 0:m I can define this matrix by loop or some apply function, however, the outer function should be the most straitforward way. How to deal with it? Thanks. Regards, Zhen
On 5/26/05, Zhen Pang <nusbj at hotmail.com> wrote:
Dear all, I'd like to define a k by k matrix where the element is defined by mn<-function(m,n) sum(choose(m,(m-0:m))*choose((k-m),(n-m+0:m))) the mn function works fine for scalar m and n, however, it fails to define the matrix by outer. a<-outer(1:k,1:k,mn) gives error message: Error in outer(1:k, 1:k, mn) : dim<- : dims [product 64] do not match the length of object [1] In addition: Warning messages: 1: Numerical expression has 64 elements: only the first used in: 0:m 2: Numerical expression has 64 elements: only the first used in: 0:m I can define this matrix by loop or some apply function, however, the outer function should be the most straitforward way. How to deal with it? Thanks.
Check out ?outer where it mentions that the function must be able to handle vector arguments. Yours does not but you can transform it to one which does using mapply: outer(1:k, 1:k, function(x,y) mapply(mn, x, y))