gpt4 book ai didi

r - 如何查看解析后的 R 函数的内容?

转载 作者:行者123 更新时间:2023-12-05 00:08:20 25 4
gpt4 key购买 nike

R 是 a functional programming language ,它的主要好处之一是能够创建开放和透明的功能。

正如约翰钱伯斯所说 in his excellent book "Software for Data Analysis: Programming with R" :

Computations are organized around functions, which can encapsulate specific, meaningful computational results, with implementations that can be examined for correctness.



“可重复的研究”和“值得信赖的软件”等概念是 R 开发的核​​心。通常,只需键入不带括号的名称即可轻松检查函数。例如:
> which
function (x, arr.ind = FALSE)
{
if (!is.logical(x))
stop("argument to 'which' is not logical")
wh <- seq_along(x)[x & !is.na(x)]
dl <- dim(x)
...

我的问题是:你如何举例说明 for() 等函数的内容?或 if()无需下载 R 源代码?

编辑:顺便说一句,我知道这无助于查看可能从 R 调用的编译代码(例如 C、C++ 或 Java)。我真的想知道是否有一个 R 函数可以输出 R 函数。

最佳答案

俗话说:用源,卢克!

R 函数可能在提示符下可见,但仍会被解析,这意味着删除注释、更改代码缩进等。所以我总是会去源代码。

关于r - 如何查看解析后的 R 函数的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1560397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com