Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninformative error message if comments within a function are #' rather than # #1605

Open
setgree opened this issue Apr 9, 2024 · 0 comments

Comments

@setgree
Copy link

setgree commented Apr 9, 2024

I was getting a befuddling x when I tried to devtools::build() on the d_calc function in this package:

✖ d_calc.R:24: @export must be a single line, not 14.
ℹ The first line is "Calculate Cohen's D or Glass's $\Delta$ based on effect size and
sample SD"

ChatGPT helped me diagnose the problem after multiple tries: #` comments in the function, e.g.

d_calc <- function(stat_type, stat, sample_sd, n_t, n_c) {
  #' Calculate Cohen's D or Glass's $\Delta$ based on effect size and sample SD
  if (stat_type == "d_i_d" || stat_type == "d_i_m" || stat_type == "reg_coef" ||
      stat_type == "beta") {
    d <- round(stat / sample_sd, digits = 3)
  } else if (stat_type == "d") {
    #' Directly use the reported change of SDs

Roxygen was treating #` comments as part of the structured text it produces documentation from. I had no idea, and googling this is tricky because # and #` are special characters.

Is an informative error message possible? Maybe a pointer to some materials on commenting conventions and what Roxygen does and does not interpret as meaningful?

Related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant