How to Get the Function Code in R
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://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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET10 - 预览版1新功能体验(一)