Skip to content

Commit

Permalink
set initialize method
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrue committed Jul 30, 2024
1 parent c8a3422 commit d26470d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vignettes/workshop_isee_extension.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,21 @@ For this, the new class needs an additional slot to store the number of hexagona
setClass("ReducedDimensionHexPlot", contains="ReducedDimensionPlot", slots=c(BinResolution = "numeric"))
```

To properly initialise instances of the new class, the new slot must be populated with a default value in the event that users do not specify a bin resolution.

For this, we need to create a new method for the generic `initialize()` and the new class.
We set the default resolution to 100 hexagonal bins along each axis.

```{r}
setMethod("initialize", "ReducedDimensionHexPlot", function(.Object, ...) {
args <- list(...)
args <- .emptyDefault(args, .plotBinResolution, 100)
do.call(callNextMethod, c(list(.Object), args))
})
```

### Creating a constructor function

It is best practice to give users a function to create objects a particular class.
Expand Down

0 comments on commit d26470d

Please sign in to comment.