我想知道获取 R 中任何辅助函数(以区别于原始/内部函数)的 C/C++ 源代码的正确方法是什么。 相关问题有here , here , here和 here :
我的不同,因此我在问题中使用了“次要”。 例如,我在 R 控制台中得到的 read.table() 函数:
>?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代码,如果这合理的话?
最佳答案
可搜索的 R 源代码位于 https://github.com/wch/r-source对此确实很有用:
- 首先我们可以查找
read.table
definition actual data reading由
scan
完成最终使用的函数.Internal(scan(file, what, nmax, sep, dec, quote, skip, nlines, [...]
- 现在
扫描
是mapped至do_scan
所以你在这里:read.table
的底层 C 实现可以在 src/main/scan.c
中找到,从函数 do_scan 开始
.
关于c++ - 如何获取R的辅助函数的C/C++源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52545380/