首页 > 解决方案 > 如何获取 R 的辅助函数的 C/C++ 源代码?

问题描述

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

我的不同,所以我在我的问题中使用了“次要”。例如,我在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代码?

标签: c++crfunction

解决方案


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

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


推荐阅读