functions with backticked argument names don't `document()` correctly?

Here's a test source file:

#' A function with argument names defined using backticks
#'
#' More information about this function.
#'
#' @param `arg 1` a number
#' @param `arg 2` a string
#'
#' @return the string `"goodbye"`
#' @export
#'
#' @examples
#' function_with_backticked_arg_names()
function_with_backticked_arg_names = function(
    `arg 1` = 1,
    `arg 2` = "apple")
{
  print(`arg 1`)
  print(`arg 2`)
  return('goodbye')
}

Here's what I get:

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/function_with_backticked_arg_names.R
\name{function_with_backticked_arg_names}
\alias{function_with_backticked_arg_names}
\title{A function with argument names defined using backticks}
\usage{
function_with_backticked_arg_names(`arg 1` = 1, `arg 2` = "apple")
}
\arguments{
\item{`arg}{2` a string}
}
\value{
the string \code{"goodbye"}
}
\description{
More information about this function.
}
\examples{
function_with_backticked_arg_names()
}

Note that arg 1 is totally missing from the documentation, and arg 2 has gotten parsed incorrectly (I think?).

In case it's helpful, I created a test package with this function included and renv activated, here:

I realize that using backticks in argument names is probably a rare practice, but I use them somewhat frequently, for example so that I can use conditional probability expressions, such as p(X|Y), as arguments.

If this is an issue with devtools::document then I recommend raising an issue at Issues ยท r-lib/devtools ยท GitHub

I don't understand why using an argumentname with spaces would solve a problem that you have with an argumentname without spaces. ?

I imagine its a matter of presentation; similar to how Julia language will let you have parameters which are whatever unicode ...

As with variables, Unicode can also be used for function names:

julia> โˆ‘(x,y) = x + y
โˆ‘ (generic function with 1 method)

julia> โˆ‘(2, 3)
5

source : link

In my experience R, is not quite so liberal

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.