【问题标题】:How to get the C/C++ source code of the a secondary function of R?如何获取 R 的辅助函数的 C/C++ 源代码?
【发布时间】:2018-09-27 21:26:53
【问题描述】:

我想知道在 R 中获取任何辅助(以区别于原始/内部)函数的 C/C++ 源代码的正确方法是什么。 相关问题有herehereherehere

我的不同,所以我在我的问题中使用了“secondary”。 例如,read.table() 函数,在 R 控制台中我得到了:

>?read.table

read.table                package:utils                R Documentation

Data Input

Description:

     Reads a file in table format and creates a data frame from it,
     with cases corresponding to lines and variables to fields in the
     file.

Usage:
     read.table(file, header = FALSE, sep = "", quote = "\"'",
        ......

或者

> getAnywhere(read.table)
A single object matching ‘read.table’ was found
It was found in the following places
  package:utils
  namespace:utils
with value

function (file, header = FALSE, sep = "", quote = "\"'", dec = ".", 

     ......

    attr(data, "row.names") <- row.names
    data
}
<bytecode: 0x560ff88edd40>
<environment: namespace:utils>

搜索我得到的网站:

https://svn.r-project.org/R/trunk/src/library/utils/src/utils.c

https://svn.r-project.org/R/trunk/src/library/utils/src/utils.h

如果合理的话,如何获取read.table函数的C/C++源代码而不是R代码?

【问题讨论】:

标签: c++ c r function


【解决方案1】:

https://github.com/wch/r-source 的可搜索 R 源代码对此非常有用:

所以你在这里:read.table 的底层 C 实现可以在 src/main/scan.c 中找到,从函数 do_scan 开始。

【讨论】:

  • 谢谢拉尔夫!您的答案正是我想要的,而且再清楚不过了。
  • @Yifangt 欢迎您。随意投票/接受答案。
猜你喜欢
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-30
  • 1970-01-01
相关资源
最近更新 更多