A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/brodieG/diffobj/issues/154 below:

Be able to pass in headers · Issue #154 · brodieG/diffobj · GitHub

Hello. First off, great package! I'm incorporating it into mine now to show diffs between model files.

I can't find a way to control the headers displayed at the top of the diff. I would like to be able to pass a string to specify this. I'm not sure if this is the same thing discussed in this issue, except there you call it "banners". Specifically, I'm using diffFile(), but I would think this is relevant to any "Diff" object.

Reprex

I have a function sort of like this:

#' @param model_A file path to first model
#' @param model_B file path to second model
model_diff <- function(model_A, model_B) {
  diffobj::diffFile(
    model_A,
    model_B,
    mode = "sidebyside"
  )
}

As you can see in the screenshot (and as I think is expected), the headers read model_A and model_B. I would like to be able to name them some more informative. A bit of context: this is a private implementation function and the user will not know what model_A vs model_B means.

Hacky solution

I figured out that I'm able to change this by directly modifying the s4 object like so, but this feels like a potentially bad idea.

model_diff <- function(model_A, model_B, model_A_name, model_B_name) {
  the_diff <- diffobj::diffFile(
    model_A,
    model_B,
    mode = "sidebyside"
  )

  the_diff@etc@tar.exp <- model_A_name
  the_diff@etc@cur.exp <- model_B_name

  return(the_diff)
}

If you think that s4 structure is unlikely to change and you don't hate that, then I guess I can accomplish what I want. But like I said, I think it's probably bad practice to mess with the internals of the object like that. Thanks for the help!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4