[R] Editing of .Rd files generated by roxygen2
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sun Jul 19 23:45:19 CEST 2020
On 17/07/2020 11:17 p.m., Shaami wrote:
> Hi All
>
> Could you please guide how we can edit the .Rd files generated by roxygen2
> for better formatting?
Edit the Roxygen2 comments in your R source code, or just don't use
Roxygen2.
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.
You give examples below, but you don't say specifically what's wrong
with them.
Duncan Murdoch
>
> 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]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list