Skip to content

Commit

Permalink
updated documentation with new wtp argument for ggplot2 ceplane.plot()
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Feb 23, 2024
1 parent d4467e6 commit 8a7d01f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 15 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# BCEA 2.4.6 (dev)

* In `ceplane.plot()` for `{ggplot2}` version used the ggplot syntax thats already used for other plotting arguments so that we can now pass e.g. `wtp = list(value = 20000, colour = "blue", x = 10, y = 10, size = 4)`. This closes issue #151 so can do something like `wtp = list(size = 0)` to hide the willingness to pay text. (3d8a770)

# BCEA 2.4.6

_February 2024_
Expand Down
13 changes: 9 additions & 4 deletions R/ceplane.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#' comparisons together. Any subset of the possible comparisons can be selected
#' (e.g., `comparison = c(1,3)` or `comparison = 2`).
#' @param wtp The value of the willingness to pay parameter. Not used if
#' `graph = "base"` for multiple comparisons.
#' `graph = "base"` for multiple comparisons. For \pkg{ggplot2} can also provide
#' a list of arguments for more options (see below).
#' @param pos Parameter to set the position of the legend; for a single
#' comparison plot, the ICER legend position. Can be given in form of a string
#' `(bottom|top)(right|left)` for base graphics and
Expand Down Expand Up @@ -36,12 +37,17 @@
#' Should be of length 1 or equal to the number of comparisons.
#' \item `icer = list(color)`: a vector of colours specifying the colour(s) of the ICER
#' points. Should be of length 1 or equal to the number of comparisons.
#' \item `icer = list(size)`: a vector of colours specifying the size(s) of the ICER
#' \item `icer = list(size)`: a vector of values specifying the size(s) of the ICER
#' points. Should be of length 1 or equal to the number of comparisons.
#' \item `area_include`: logical, include or exclude the cost-effectiveness
#' acceptability area (default is TRUE).
#' acceptability area (default is `TRUE`).
#' \item `wtp = list(value)`: equivalent to simply using `wtp = value` but for when multiple
#' arguments are passed in list form.
#' \item `area = list(color)`: a colour specifying the colour of the cost-effectiveness
#' acceptability area.
#' \item `wtp = list(color)`: a colour specifying the colour of the willingness-to-pay text
#' \item `wtp = list(size)`: a value specifying the size of the willingness-to-pay text
#' \item `wtp = list(x=..., y=...)`: a value specifying the x and y coordinates of the willingness-to-pay text
#' \item `currency`: Currency prefix to cost differential values - \pkg{ggplot2} only.
#' \item `icer_annot`: Annotate each ICER point with text label - \pkg{ggplot2} only.
#' }
Expand Down Expand Up @@ -103,7 +109,6 @@ ceplane.plot.bcea <- function(he,
pos = c(0, 1),
graph = c("base", "ggplot2", "plotly"),
...) {
browser()
graph <- match.arg(graph)

he <- setComparisons(he, comparison)
Expand Down
1 change: 0 additions & 1 deletion R/ceplane_plot_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ ceplane_plot_base <- function(he, ...) {
ceplane_plot_ggplot.bcea <- function(he,
pos_legend,
graph_params, ...) {
browser()
# single long format for ggplot data
delta_ce <-
merge(
Expand Down
2 changes: 1 addition & 1 deletion R/prep_ceplane_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @keywords internal
#'
prep_ceplane_params <- function(he, wtp_params, ...) {
browser()

graph_params <- list(...)

# back compatibility
Expand Down
12 changes: 9 additions & 3 deletions man/ceplane.plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/ceplane_ggplot_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ceplane_plot_graph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/prep_ceplane_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions vignettes/ceplane.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,40 @@ ceplane.plot(he, pos = c(1, 0))
ceplane.plot(he, pos = c(1, 1))
```

### Willingness-to-pay

For `{ggplot2}`

```{r}
ceplane.plot(he, graph = "ggplot2") # default
ceplane.plot(he, graph = "ggplot2", wtp = 10000)
ceplane.plot(he, graph = "ggplot2", wtp = list(value = 10000))
ceplane.plot(he, graph = "ggplot2", wtp = list(value = 10000, colour = "blue"))
ceplane.plot(he, graph = "ggplot2", wtp = list(colour = "blue"))
ceplane.plot(he, graph = "ggplot2", wtp = list(y = 8))
ceplane.plot(he, graph = "ggplot2", wtp = list(size = 5))
# to hide text
ceplane.plot(he, graph = "ggplot2", wtp = list(size = 0))
```

For base `R`

```{r}
ceplane.plot(he) # default
##TODO: not yet implemented
# ceplane.plot(he, wtp = 10000)
# ceplane.plot(he, wtp = list(value = 10000))
# ceplane.plot(he, wtp = list(value = 10000, colour = "blue"))
# ceplane.plot(he, wtp = list(colour = "blue"))
# ceplane.plot(he, wtp = list(y = 8))
# ceplane.plot(he, wtp = list(size = 5))
#
# # to hide text
# ceplane.plot(he, wtp = list(size = 0))
```

<!-- ```{r} -->
<!-- ceac.plot(he, graph = "ggplot2", pos = c(0, 0)) -->
<!-- ceac.plot(he, graph = "ggplot2", pos = c(0, 1)) -->
Expand Down

0 comments on commit 8a7d01f

Please sign in to comment.