[R] Editing of .Rd files generated by roxygen2

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sun Jul 19 21:49:19 CEST 2020


No.
Post to r-package-devel for help with R packages.

However, roxygen2 is an Rstudio supported package, and you may need to post
on Rstudio's site for help on it.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jul 19, 2020 at 11:46 AM Shaami <nzshaam using gmail.com> wrote:

>  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]]
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list