Giter VIP home page Giter VIP logo

Comments (12)

GeoBosh avatar GeoBosh commented on May 30, 2024 1

I changed the example and added a comment about this in README on the github repo.

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024 1

Thanks, the message "possibly non-existing or duplicated key(s) in bib file" is not ideal and could, at least, be improved e.g., adding : or missing a required field).

This is a very old message (from 2018, amended in 2020). I will check why it doesn't emit the actual error message, as well.

There is the separate issue of whether Rdpack could/should render silently trivial Biblatex differences, such as using 'date' when year is missing or journaltitle if title is missing.

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

Thanks for the report and the praise :).

The second argument of the macros specifies the package from which the references should be taken, in this case package maar. Just change {Rdpack} to {maar}:

\insertCite{white1980usinglsapproxunknownregfuncs}{maar}
\insertCite{white1980heteroskedasticconsistentcovest}{maar}
For more details
\insertCite{@see also @buja2019modelsasapproximationspart1 and @buja2019modelsasapproximationspart2;textual}{maar}

You get warnings , not errors, in such cases since if you prefer to fix references later it may be frustrating not to be able to build your package.

Let me know if this solves the issue. Also, it would be useful to know if viewRd works as expected, since I have had very little feedback on it.

from rdpack.

shamindras avatar shamindras commented on May 30, 2024

Thanks @GeoBosh - that did partially help resolve the issue! I knew I'd made a simple mistake.

You get warnings , not errors, in such cases since if you prefer to fix references later it may be frustrating not to be able to build your package.

That's true, I've reflected the issue title to reflect that this is indeed a warning.
Although your suggestion to fix the references later is indeed useful, I'm trying to
document the package in as much detail as every function is written. I'll use this strategy
if we keep getting references warning issues 😄 .

Here is the revised roxygen2 comment:

#' Compute the White sandwich estimator of standard errors for
#' ordinary least squares (OLS) regression. This is based on the series of
#' papers \insertCite{white1980usinglsapproxunknownregfuncs}{maar} and \insertCite{white1980heteroskedasticconsistentcovest}{maar}. For more details \insertCite{@see also @buja2019modelsasapproximationspart1 and @buja2019modelsasapproximationspart2;textual}{maar}
#'
#' @param lm_object (lm) : lm object
#'
#' @return (matrix) : White sandwich estimator of variance for OLS regression
#' @export
#'
#' @importFrom Rdpack reprompt
#' @references
#'     \insertAllCited{}
#' @examples
#' \dontrun{
#' n <- 1e5
#' X <- stats::rnorm(n, 0, 1)
#' y <- 2 + X * 1 + stats::rnorm(n, 0, 10)
#' lm_fit <- stats::lm(y ~ X)
#' sandwich_qr_var <- comp_sandwich_qr_var(lm_fit)
#' }

I mention partially resolve, because when I use viewRd I get the attached screenshot.

viewRd_maar_01

  1. It seems like the references in the main description are indented in a strange way e.g see "for more details..." appears on a new line on a different indentation
  2. The insertAllCited{} does not seem to render the references

Any ideas what may be the issue?

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

Regarding '1. It seems like the references in the main description are indented in a strange way e.g see "for more details..." appears on a new line on a different indentation', I don't observe it on my side and more information is needed. If you are rendering it as html in Rstudio, it is probably the way it renders titles. Notice that it takes the text as a title which it probably renders centred. But it is extremely long, so the first line takes the whole line, while the second is incomplete and centred (I think, that is not indentation but centring, but I may be wrong). You probably didn't intend this to be a title but if you did, please follow up with more details.

Regarding "2. The insertAllCited{} does not seem to render the references".

Short answer: don't indent \insertAllCited{} by four spaces - any other number of spaces, including zero, will do. For example:

#' @references
#' \insertAllCited{}

or even

#' @references \insertAllCited{}

Long answer: This is a markdown feature, which seems to be used by roxygen2 - lines indented by exactly four spaces are rendered verbatim. In this case the following chunk in your R file

#' @references
#'     \insertAllCited{}

is translated to the following snipped in the Rd file:

\references{
\preformatted{\\insertAllCited\{\}
}

\preformatted is the Rd syntax for verbatim, so the command inside it is not interpreted at all.

I will mention the above in the documentation but I am surprised that it was not reported before.

from rdpack.

shamindras avatar shamindras commented on May 30, 2024

Thanks again @GeoBosh

  1. The first issue is resolved. I should have put the first line as a title, and left a blank line for the before the description. One minor thing, and I don't believe this is an Rdpack issue, but there is an extra line and indentation after the lm_object in the Arguments section. I expected the description to be on the same line. Just wanted to check before I investigated this further (please see screenshot below).
New roxygen2 comment

#' Compute the White sandwich estimator of standard errors for OLS
#'
#' Compute the White sandwich estimator of standard errors for
#' ordinary least squares (OLS) regression, \insertCite{@see @white1980usinglsapproxunknownregfuncs and @white1980heteroskedasticconsistentcovest;textual}{maar}. For
#' more details
#' \insertCite{@see also @buja2019modelsasapproximationspart1 and @buja2019modelsasapproximationspart2;textual}{maar}.
#'
#' @param lm_object An lm (OLS) object
#'
#' @return (matrix) White sandwich estimator of variance for OLS regression
#'
#' @export
#'
#' @importFrom Rdpack reprompt
#'
#' @references \insertAllCited{}
#'
#' @examples
#' \dontrun{
#' n <- 1e5
#' X <- stats::rnorm(n, 0, 1)
#' y <- 2 + X * 1 + stats::rnorm(n, 0, 10)
#' lm_fit <- stats::lm(y ~ X)
#' sandwich_qr_var <- comp_sandwich_qr_var(lm_fit)
#' }

viewRd_maar_02

  1. The second issue is also resolved with your suggestions - thanks! However, I had copied the indented block directly from the Rdpack README file. See the citations section, the roxygen2 @references is indented there.

in roxygen2, the references chunk might look like this:

#' @references
#'     \insertAllCited{}

Perhaps it should be replaced with the suggestion you have provided to help future users?

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

Regarding 2., I noticed that my example uses exactly four spaces! This must be relatively recent feature of roxygen2, since I myself have copied that line (though I don't use roxygen2 much).

The text for Description is typically rendered as a separate paragraph. As to the arguments, in the text rendering I get the explanation on the same line but in pdf and html they are on new line - again, a design decision. This may also depend on the number of characters in the argument's name. viewRd doesn't do the rendering, it just makes sure that the call to the relevant R functions contain the definitions of the citation macros.

from rdpack.

shamindras avatar shamindras commented on May 30, 2024

Regarding 2., I noticed that my example uses exactly four spaces! This must be relatively recent feature of roxygen2, since I myself have copied that line (though I don't use roxygen2 much).

I see. I'm using roxygen2_7.1.1 for reference and the 4 spaces gave me the issue. It may be good to mention both ways of writing this for roxygen2 depending on the version that the user has installed.

The text for Description is typically rendered as a separate paragraph. As to the arguments, in the text rendering I get the explanation on the same line but in pdf and html they are on new line - again, a design decision. This may also depend on the number of characters in the argument's name. viewRd doesn't do the rendering, it just makes sure that the call to the relevant R functions contain the definitions of the citation macros.

Thanks, I will take a further look at the roxygen2 details for this. Appreciate your explanation.

Please feel free to mark this issue as closed.

from rdpack.

shamindras avatar shamindras commented on May 30, 2024

I changed the example and added a comment about this in README on the github repo.

Looks great - thanks again for your help on this, and for creating such a nice documentation tool!

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

Thanks for the report, too.

from rdpack.

ms609 avatar ms609 commented on May 30, 2024

Just noting that another possible cause of the "possibly non-existing or duplicated key(s) in bib file" warning is unexpected formatting in a bib entry.

I encountered the message when devtools::check_man()ing a package containing

@article{MyKey,
  title = {Some study},
  author = {Body, Some},
  date = {2021}
}

When I installed the package, I also saw a message pointing out that A bibentry of bibtype 'Article' has to specify the field: year.
Indeed, replacing the date field with year allowed the key to be recognized, resolving the issue.

I'm not sure that there's anything that Rdpack can easily do to flag this up as a cause, so am not opening as a new issue, but thought I'd add the note here in case it helps others.

from rdpack.

ms609 avatar ms609 commented on May 30, 2024

Thanks! And for what it's worth, Zotero/BetterBibTex uses journaltitle as an alias for journal (rather than title) – not sure if other software uses this field differently.

from rdpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.