首页 > 其他 > 详细

How to Get the Function Code in R

时间:2016-04-30 22:21:44      阅读:337      评论:0      收藏:0      [点我收藏+]

http://fhqdddddd.blog.163.com/blog/static/1869915420104111031148/

 

http://blog.sina.com.cn/s/blog_61f013b80100gekp.html

http://rbbs.biosino.org/Rbbs/posts/list/1073.page

 

 

How to Get the Function Code in R

R is “open-access”, so I can read and modify the function code for further application. And that is the reason I choose it, use it and love it.

 

But first, let’s explore how to get the function code.

1. On R Console. function_name + Enter. For example:

> fivenum

function (x, na.rm = TRUE)

{

    xna <- is.na(x)

    if (na.rm)

        x <- x[!xna]

    else if (any(xna))

        return(rep.int(NA, 5))

    x <- sort(x)

    n <- length(x)

    if (n == 0)

        rep.int(NA, 5)

    else {

        n4 <- floor((n + 3)/2)/2

        d <- c(1, n4, (n + 1)/2, n + 1 - n4, n)

        0.5 * (x[floor(d)] + x[ceiling(d)])

    }

}

<environment: namespace:stats>

2. function_name.default. For example:

>qqnorm.default

# this is a visible function, a special case of 3 later.

3. For generic functions like “rep”

>t.test

function (x, ...)

UseMethod("t.test")

<environment: namespace:stats>

 

>methods(“t.test”)

 [1] t.test.default* t.test.formula*

   Non-visible functions are asterisked

# first, we should known the “methods” used.

 

>getAnywhere(“t.test.default”)  or >stats:::t.test.default or >getS3method(“t.test”,“default”)

# get “t.test.default” code

4.  If all the methods discussed above cannot help, just open the R-code(.tar.gz) for the Z-plan.

 

 

For more:

http://cran.csdb.cn/

http://rbbs.biosino.org/Rbbs/posts/list/63.page#574#574

http://www.pinggu.org/bbs/b69i336419.html

http://cos.name/bbs/read.php?tid=1065

http://tel.pinggu.org/bbs/b69i456670p4.html

 

In addition, thanks for Dr. Ding’s prompt help and discussion about the “wilcox.test” function code in R.

How to Get the Function Code in R

原文:http://www.cnblogs.com/arcserver/p/5449503.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!