[Bioc-devel] Fwd: Question about a package submission
Martin Morgan
martin.morgan at roswellpark.org
Thu Oct 27 14:36:31 CEST 2016
Since no one else took the bait, I'll try to answer...
On 10/25/2016 06:57 PM, Ioannis Vardaxis wrote:
>
>
> Ioannis Vardaxis
> Stipendiat NTNU
> Sendt fra min iPhone
>
> Videresendt melding:
>
> Fra: "bioconductorseattle at gmail.com<mailto:bioconductorseattle at gmail.com>" <bioconductorseattle at gmail.com<mailto:bioconductorseattle at gmail.com>>
> Dato: 26. oktober 2016 kl. 00.55.14 CEST
> Til: Ioannis Vardaxis <ioannis.vardaxis at math.ntnu.no<mailto:ioannis.vardaxis at math.ntnu.no>>
> Emne: Re: Question about a package submission
>
> On 10/25/2016 06:52 PM, Ioannis Vardaxis wrote:
> Hi,
>
> I have a problem documenting multiple functions in one rd file using
> roxygen2. I tried to find the solution on the internet with no results.
> I have for example 2 plot functions for class1 and class2 and I want to
> make a plot-method.R as the Bioconductor guideline suggests.
>
> What I have in the plot-method.R is the following code:
>
> Please ask questions about Bioconductor package development on the bioc-devel mailing list.
>
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>
> Martin
>
>
> #' @title Plot methods
> #' @author ...
> #'
> #' @references ...
> #'
> #' @description something
> #' @param x An x of correct class.
> #' @param ... something
> #'
> #' @seealso something
> #'
> #' @rdname plot
> # @export plot
> #' @include AllClasses.R #this where class1 and class2 are defined.
> #?#'?packages I need
> #' @importFrom plyr ddply . ldply laply
> #' @importFrom utils methods
> #' @importFrom S4Vectors metadata
>
> #define the plot function which is in base in R:
> plot <- function(x, ...){
> UseMethod("plot")
> }
plot is already an S3 generic (from graphics) and an S4 generic (from
stats4) so it is a mistake to redefine it. Whatever the documentation
issues this part should be removed.
>
>
> #define the other plot function for my classes:
> #?class1
> #' @rdname plot
> #' @method plot class1
> #' @return something
> #' @export
> plot.class1=function(x,...){
> code
> }
> #?class2
> #' @rdname plot
> #' @method plot class2
> #' @return something
> #' @export
> plot.class2=function(x,...){
> code
> }
>
>
>
> When I generate with roxygen I am then able to write ??Mypkg::plot and I
> get nice rd files. However when I try to use plot for an x object of
> class1 or class2 then I get the following error:
> Error in as.vector(x, mode = "numeric") :
> no method for coercing this S4 class to a vector
>
>
> If on the other hand I remove the first code:
> plot <- function(x, ...){
> UseMethod("plot")
> }
>
>
> Then I am able to run the plot functions correctly with no error, but then
> in the help in R I have to write ??Mypkg::plot.class1 and the main
> S3method is plot.class1.
Or ?"plot<tab>" completing to ?plot.class1. But this is the way the help
system works -- you're looking for help not on the generic, but on the
method. I believe that you _could_ define @aliases plot, and
?MyPkg::plot would take you to the correct help page. But then ?plot
would prompt the user to choose between your (method) documentation and
base R (generic) documentation. This doesn't seem to be a good idea.
One possibility is to avoid the 'plot' generic anyway and use something
more discriptive for how your object is being displayed, perhaps
justifying with the notion that the representation produced by your plot
differs from the representation described in ?plot.
Martin
> How can I solve this in a way that I write ??Mypkg::plot and get all the
> methods in one script and at the same time the plot.class1,2 work properly?
>
>
>
>
>
>
> Best,
> Ioannis
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>
This email message may contain legally privileged and/or...{{dropped:2}}
More information about the Bioc-devel
mailing list