0

I have created a function plot.tukey that builds a custom graphic using the base plotting tools, overlaying multiple plot calls with par(new=TRUE).

When I documented with roxygen2, it added an S3method wrapper on the function to NAMESPACE

# Generated by roxygen2: do not edit by hand

S3method(plot,tukey)


export(color.randomHEX)

Question 1: Do I always want such an automatic wrapper?

What are the advantages / disadvantages of inheriting methods("plot")?

Question 2: If I choose to NOT want this function to be tied to the S3method, how do I tell roxygen2?

Why did roxygen2 assume I wanted this function attached to S3? Only based on the name of the function? Regardless, how do I tell roxygen2 to export AS-IS, without S3 as it did with the function color.randomHEX?

Dharman
  • 30,962
  • 25
  • 85
  • 135
mshaffer
  • 959
  • 1
  • 9
  • 19
  • If you name your function `plot.tukey` that's the convention that S3 uses. If you don't want S3, to avoid cofunction, it would be better to use something like `plot_tukey` as the name of the function. But you can export both an S3 version and the full function by adding a second export. See https://stackoverflow.com/questions/18512528/how-to-export-s3-method-so-it-is-available-in-namespace – MrFlick Aug 22 '22 at 13:08
  • @MrFlick How to use `plot.tukey` but tell R, "I don't want to be part of the `methods('plot')` namespace?" How to `delist` from the namespace? – mshaffer Aug 22 '22 at 13:11
  • I think you just need to use `@export plot.tukey` but you didn't provide a reproducible example so I can't easily test. This is really an `roxygen` thing because it tried very hard to do the "right" thing based on your function names. If you manually edited your NAMESPACE file you could put whatever you want in there. – MrFlick Aug 22 '22 at 13:16
  • https://github.com/r-lib/roxygen2/issues/243 says be explicit with `@export`. In the above example, I just used `@export` *NOT* `@export plot.tukey` ... – mshaffer Aug 22 '22 at 13:19

0 Answers0