Skip to content

Commit d62bdc3

Browse files
authored
Add minor plot() docstring polish (#106)
1 parent 3414449 commit d62bdc3

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

r-package/maq/R/plot.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#'
2222
#' @examples
2323
#' \donttest{
24-
#' if (require("ggplot2", quietly = TRUE)) {
2524
#' # Generate toy data and customize plots.
2625
#' n <- 500
2726
#' K <- 1
@@ -30,15 +29,16 @@
3029
#' cost <- 1
3130
#'
3231
#' # Fit Qini curves.
33-
#' qini.avg <- maq(reward, cost, scores, R = 200, target.with.covariates = FALSE)
3432
#' qini <- maq(reward, cost, scores, R = 200)
33+
#' qini.avg <- maq(reward, cost, scores, R = 200, target.with.covariates = FALSE)
3534
#'
36-
#' # In some settings we may want to plot using one of R's many plot libraries.
37-
#' # The plot method invisibly returns the plot data we can use for this purpose.
35+
#' # The plot method invisibly returns the plot data as a data.frame,
36+
#' # which allows for custom plotting with external libraries.
3837
#' df.qini.baseline <- plot(qini.avg)
39-
#' df.qini <- plot(qini, add = TRUE, col = 2)
38+
#' df.qini <- plot(qini, add = TRUE, col = "red")
4039
#'
4140
#' # Make an alternate plot style, using, for example, ggplot.
41+
#' if (require("ggplot2", quietly = TRUE)) {
4242
#' ggplot(df.qini, aes(x = spend, y = gain)) +
4343
#' geom_ribbon(aes(ymin = gain - 1.96 * std.err,
4444
#' ymax = gain + 1.96 * std.err),
@@ -48,8 +48,11 @@
4848
#' xlab("Fraction treated") +
4949
#' geom_line(data = df.qini.baseline, aes(x = spend, y = gain), lty = 2)
5050
#' }
51-
#' }
5251
#'
52+
#' # `scale_maq()` rescales policy gain curves for specific application units.
53+
#' # Plot policy values for a maximum allocation of, for example, 500 units.
54+
#' plot(scale_maq(qini, 500), xlab = "Units treated")
55+
#' }
5356
#' @method plot maq
5457
#' @export
5558
plot.maq <- function(x,

r-package/maq/man/plot.maq.Rd

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r-package/maq/pkgdown/_pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ reference:
2020
- average_gain
2121
- difference_gain
2222
- integrated_difference
23-
- scale_maq
2423
- get_ipw_scores
2524
- get_aipw_scores
2625

2726
- title: Plotting and printing
2827
contents:
2928
- plot.maq
3029
- print.maq
30+
- scale_maq
3131
- summary.maq

0 commit comments

Comments
 (0)