r - Rcpp 在两个函数之间共享相同的 roxygen
问题描述
考虑以下函数:
//' Provides some stuff AB
//' @param a integer that responsible for stuff A
//' @param b integer that responsible for stuff B
//' @export
// [[Rcpp::export]]
NumericVector foo1(int a, int b)
{
//some code
}
//' Provides some stuff AC
//' @param a integer that responsible for stuff A
//' @param c integer that responsible for stuff C
//' @export
// [[Rcpp::export]]
NumericVector foo2(int a, int c)
{
//some code
}
请注意,对于 foo1 和 foo2,参数a 的描述应该相同。我有许多功能,应该以相同的方式提供参数描述。每次我分别为每个函数需要它时,我都不想复制过去的参数描述。是否可以指定描述并将其应用于我的 Rcpp 包提供的所有功能?
将非常感谢您的帮助!
解决方案
感谢 Dirk Eddelbuettel,我找到了答案:
//' @name sharable
//' @rdname sharable
//' @param a integer that responsible for stuff A
//' @export
//' Provides some stuff AB
//' @rdname sharable
//' @param b integer that responsible for stuff B
//' @export
// [[Rcpp::export]]
NumericVector foo1(int a, int b)
{
//some code
}
//' Provides some stuff AC
//' @rdname sharable
//' @param c integer that responsible for stuff C
//' @export
// [[Rcpp::export]]
NumericVector foo2(int a, int c)
{
//some code
}
推荐阅读
- c# - Google Speech API - 可以获得音素成绩单吗?
- regex - 一个正则表达式可进行 0、1 或 n 次文本替换
- html - 如何将模型中的项目显示为视图中的链接
- composer-php - 无法在 Artifactory 包视图中选择 PHP Composer
- javascript - 将两个不同的关联数组放在一个关联数组中,作为一个在javascript中具有两个关联数组的数组
- python - 使用列名和 dtypes 加载 pandas 表
- twilio - Twilio statusCallback 不会触发
- r - glmulti:为具有两个嵌套随机变量的 glmer 分配预测函数
- regex - 正则表达式 - 如何在动态文件夹名称中查找文件
- nginx - 在 aws ec2 Linux 内核 4.14 实例上的 ansible 上安装 nginx 时出错