[R] Editing of .Rd files generated by roxygen2
Shaami
nz@h@@m @end|ng |rom gm@||@com
Sat Jul 18 05:17:31 CEST 2020
Hi All
Could you please guide how we can edit the .Rd files generated by roxygen2
for better formatting? I get the function and its input arguments into
multiple lines in the PDF file. Also, I do not get \usage{} line in .Rd
file for an Rcpp functions.
An example of an .Rd file and its corresponding R file are as follows:
____________________
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sumEx.R
\name{SumEx}
\alias{SumEx}
\alias{sumEx}
\title{sum of objects}
\usage{
SumEx(
FirstVector,
SecondVector,
ThirdVector,
FourthVector,
FifthVector,
SixthVector
)
}
\arguments{
\item{FirstVector}{is a vector of length \eqn{n}.}
\item{SecondVector}{is a vector of length \eqn{n}.}
\item{ThirdVector}{is a vector of length \eqn{n}.}
\item{FourthVector}{is a vector of length \eqn{n}.}
\item{FifthVector}{is a vector of length \eqn{n}.}
\item{SixthVector}{is a vector of length \eqn{n}.}
}
\description{
COmputes the sum of objects
}
#' sum of objects
#'
#' COmputes the sum of objects
#' @aliases sumEx
#' @param FirstVector is a vector of length \eqn{n}.
#' @param SecondVector is a vector of length \eqn{n}.
#' @param ThirdVector is a vector of length \eqn{n}.
#' @param FourthVector is a vector of length \eqn{n}.
#' @param FifthVector is a vector of length \eqn{n}.
#' @param SixthVector is a vector of length \eqn{n}.
#' @import stats Rcpp
#' @importFrom Rcpp sourceCpp
#' @export
#'
SumEx <- function(FirstVector, SecondVector, ThirdVector, FourthVector,
FifthVector, SixthVector)
{
sumall <- sum(FirstVector, SecondVector, ThirdVector, FourthVector,
FifthVector, SixthVector)
return(sumall)
}
---------------------------------------------------------
An example of an .cpp() function and its corresponding .Rd() file are as
follows:
//' Probability density function of gamma distribution
//'
//' Calculates the PDF of gamma distribution
//' @name dgammaC
//' @aliases dgammaC
//' @param x is the observed data.
//' @param alpha is the shape parameter of gamma distribution.
//' @param beta is the scale parameter of gamma distribution.
//' @param give_log is an integer for logirthm. If 0, then no logrithm of
PDF is considered.
//' @return PDF of gamma distribution
//' @export
//'
#include <Rcpp.h>
using namespace Rcpp;
//[[Rcpp::export]]
NumericVector dgammaC(NumericVector x, double alpha, double beta, int
give_log)
{
int T = x.size();
NumericVector f(T);
for(int t=0;t<T; t++)
{
f(t) = R::dgamma(x(t), alpha, beta, give_log);
}
return f;
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{dgammaC}
\alias{dgammaC}
\title{Probability density function of gamma distribution}
\arguments{
\item{x}{is the observed data.}
\item{alpha}{is the shape parameter of a gamma distribution.}
\item{beta}{is the scale parameter of a gamma distribution.}
\item{give_log}{is an integer for logarithm. If 0, then no logarithm of PDF
is considered.}
}
\value{
PDF of the gamma distribution
}
\description{
Calculates the PDF of gamma distribution
}
Thank you
Regards
[[alternative HTML version deleted]]
More information about the R-help
mailing list