我正在使用Rcpp
构建R包。我在源cpp文件中添加了roxygen2
样式注释,但在构建包和R/RcppExports.R
后,这些注释未反映在src/RcppExports.cpp
和devtools::document()
中。
#include <RcppArmadillo.h>
#include <Rcpp.h>
using namespace Rcpp;
//' @title Linearc
//' @description Computes the linear regression coefficient estimates
(ridge-penalization and weights, optional)
//' @param X matrix
//' @param y matrix
//' @param lam optional tuning parameter for ridge regularization term.
Defaults to 'lam = 0'
//' @param weights optional vector of weights for weighted least squares
//' @param intercept add column of ones if not already present. Defaults to
TRUE
//' @param kernel use linear kernel to compute ridge regression
coefficeients. Defaults to true when p >> n
//' @return returns the coefficient estimates
//' @export
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
List linearrc(const arma::mat& X, const arma::colvec& y, double lam = 0,
arma::colvec weights = 0, bool intercept = true, bool kernel = false) {
...
R/RcppExports.R
中没有修改:# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
linearrc <- function(X, y, lam = 0, weights = 0L, intercept = TRUE, kernel =
FALSE) {
.Call('statr_linearrc', PACKAGE = 'statr', X, y, lam, weights, intercept,
kernel)
}
src/RcppExports.cpp
中没有修改:// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <Rcpp.h>
using namespace Rcpp;
// linearrc
List linearrc(const arma::mat& X, const arma::colvec& y, double lam,
arma::colvec weights, bool intercept, bool kernel);
RcppExport SEXP statr_linearrc(SEXP XSEXP, SEXP ySEXP, SEXP lamSEXP, SEXP
weightsSEXP, SEXP interceptSEXP, SEXP kernelSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type X(XSEXP);
Rcpp::traits::input_parameter< const arma::colvec& >::type y(ySEXP);
Rcpp::traits::input_parameter< double >::type lam(lamSEXP);
Rcpp::traits::input_parameter< arma::colvec >::type weights(weightsSEXP);
Rcpp::traits::input_parameter< bool >::type intercept(interceptSEXP);
Rcpp::traits::input_parameter< bool >::type kernel(kernelSEXP);
rcpp_result_gen = Rcpp::wrap(linearrc(X, y, lam, weights, intercept,
kernel));
return rcpp_result_gen;
END_RCPP
}
我已将#' @useDynLib <pkg-name>
和#' @importFrom Rcpp sourceCpp
包含在包中的随机.R文件中。我正在使用最新版本的Rstudio和Roxygen2。
此外,linearrc
函数未以export(linearrc)
形式显示在NAMESPACE中...
谢谢!