>>>>> Lukas Lehnert via R-devel 
>>>>>     on Fri, 22 May 2020 12:26:05 +0200 writes:

    > Dear R Developers,
    > the new  simplify argument in apply causes that my package (hsdar) does 
not 
    > pass the 
    > checks in R-devel.

    > The workaround, Kurt Hornik send me, is working for the R-code:
    > if("simplify" %in% names(formals(base::apply))) 
    > do something 
    > else 
    > do something else

    > Unfortunately, I cannot conditionalize the man pages of the functions. 

Why should you do that?   In other words:  Why change the
argument list of your function(s) ?

That \Sexpr{} does not work as a section is "obvious" (for some),
but I really don't see why you should change the argument list
or defaults of your hdara package functions at all.

Martin Maechler
ETH Zurich  and  R Core

    > I get the message 
    > that "applySpeclib.Rd:12-14: Section \Sexpr is unrecognized and will be 
    > dropped" if I try to 
    > dynamically define the entire usage section. If I try to use \Sexpr 
inside the 
    > \usage section, 
    > I get the following warning: "applySpeclib.Rd:13-15: Tag \Sexpr is 
invalid in 
    > a \usage block"

    > Does anybody have an idea how to proceed. The full code is available 
below.

    > Thanks

    > Lukas


    > *1. Code for full usage section:*
    > ..
    > \description{
    > Apply function over all spectra or a subset of spectra in a 
\code{Speclib}.
    > }

    > \Sexpr[echo=TRUE,results=rd,stage=install]{
    > hsdar:::.applyInHelp1("Speclib", usage = TRUE)
    > }

    > \arguments{
    > ..

    > *Function .applyInHelp1*
    > .applyInHelp1 <- function(fun_name, usage)
    > {
    > if (usage)
    > {
    > if ("simplify" %in% names(formals(base::apply))) 
    > {
    > return(paste0("\\usage{\n",
    > "\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ..., 
    > simplify = TRUE)\n",
    > "}"))
    > } else {
    > return(paste0("\\usage{\n",
    > "\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ...)
    > \n",
    > "}"))
    > }
    > } else {
    > if ("simplify" %in% names(formals(base::apply))) 
    > {
    > return("}\n\\item{simplify}{Currently ignored")
    > } else {
    > return("")
    > }
    > }
    > }


    > *2. Using \Sexpr inside the \usage block*
    > \usage{
    > \S4method{apply}{Speclib}(X, FUN, bySI = NULL, ...
    > \Sexpr[echo=TRUE,results=rd,stage=install]{
    > hsdar:::.applyInHelp2(usage = TRUE)
    > }
    > )
    > }


    > *Function .applyInHelp2*
    > .applyInHelp2 <- function(usage)
    > {
    > if (usage)
    > {
    > if ("simplify" %in% names(formals(base::apply))) 
    > {
    > return(", simplify = TRUE)")
    > } 
    > } else {
    > if ("simplify" %in% names(formals(base::apply))) 
    > {
    > return("}\n\\item{simplify}{Currently ignored")
    > } else {
    > return("")
    > }
    > }
    > }

    > ______________________________________________
    > R-devel@r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to