Let's say I am writing a small R package including two functions with exaclty the same arguments except one. Here is an example:
fct1 <- function(r, K){...}
fct2 <- function(r, p, K){...}
In my roxygen2 documentation of the first function I use the following tags:
#' @param r description of argument r
#' @param K description of argument K
For the second function, I use the following tags:
#' @param p description of argument p
#' @inheritParams fct1
After processing my code with roxygenize, the .Rd file for the function fct2 presents the arguments in the following order: p, r, K. I would like them to be in the same order than in the usage section, that is: r, p, K. How can I get this order without manually changing the .Rd file?
I insist on using @inheritParams to avoid copying and pastings.
Thanks!
I have the same problem. For now I use little trick to avoid wrong arguments order.
Use code (e.g. in seperate .R file):
#' Function arguments
#'
#' @keywords integral
#'
#' @name fargs
#'
#' @param r ..
#' @param p ..
#' @param K ..
#'
#'
NULL
and use
#' @inheritParams fargs
for both functions.
In this case it was easy, but in more complicated examples U can use many blocks of this code (separate block for every type of arguments). Maybe it is not so simple way but you do not repeat the same code anywhere. I store that block in seperate args.R file so every inherit arguments is in one file.
Another way is using templates but this method is not flexible and for every block you must create separate .R file. So I advice u to use simmilary blocks of code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With