1- # ' Get or view the names of available plotting functions
1+ # ' Get or view the names of available plotting or data functions
22# '
33# ' @export
44# ' @param pattern,fixed,invert Passed to [base::grep()].
5+ # ' @param plots_only If `TRUE` (the default) only plotting functions are
6+ # ' searched for. If `FALSE` then functions that return data for plotting
7+ # ' (functions ending in `_data()`) are also included.
58# ' @return A possibly empty character vector of function names with several
69# ' additional attributes (for use by a custom print method). If `pattern`
710# ' is missing then the returned object contains the names of all available
8- # ' plotting functions in the [MCMC] or [PPC ] module, depending on
11+ # ' plotting functions in the [MCMC], [PPC], or [PPD ] module, depending on
912# ' which function is called. If `pattern` is specified then a subset of
1013# ' function names is returned.
1114# '
1215# ' @examples
1316# ' available_mcmc()
1417# ' available_mcmc("nuts")
1518# ' available_mcmc("rhat|neff")
19+ # '
20+ # ' available_ppc()
1621# ' available_ppc("grouped")
1722# ' available_ppc("grouped", invert = TRUE)
1823# '
19- available_ppc <- function (pattern = NULL , fixed = FALSE , invert = FALSE ) {
20- .list_module_functions(" ppc" ,
21- .pattern = pattern ,
22- fixed = fixed ,
23- invert = invert )
24- }
24+ # ' available_ppd()
25+ # ' available_ppd("grouped")
26+ # '
27+ # ' # can also see which functions that return data are available
28+ # ' available_ppc(plots_only = FALSE)
29+ # '
30+ # ' # only show the _data functions
31+ # ' available_ppc("_data", plots_only = FALSE)
32+ # ' available_ppd("_data", plots_only = FALSE)
33+ # ' available_mcmc("_data", plots_only = FALSE)
34+ # '
35+ available_ppc <-
36+ function (pattern = NULL ,
37+ fixed = FALSE ,
38+ invert = FALSE ,
39+ plots_only = TRUE ) {
40+ .list_module_functions(
41+ .module = " ppc" ,
42+ .pattern = pattern ,
43+ fixed = fixed ,
44+ invert = invert ,
45+ plots_only = plots_only
46+ )
47+ }
2548
2649# ' @rdname available_ppc
2750# ' @export
28- available_mcmc <- function (pattern = NULL , fixed = FALSE , invert = FALSE ) {
29- .list_module_functions(" mcmc" ,
30- .pattern = pattern ,
31- fixed = fixed ,
32- invert = invert )
33- }
51+ available_ppd <-
52+ function (pattern = NULL ,
53+ fixed = FALSE ,
54+ invert = FALSE ,
55+ plots_only = TRUE ) {
56+ .list_module_functions(
57+ .module = " ppd" ,
58+ .pattern = pattern ,
59+ fixed = fixed ,
60+ invert = invert ,
61+ plots_only = plots_only
62+ )
63+ }
64+
65+ # ' @rdname available_ppc
66+ # ' @export
67+ available_mcmc <-
68+ function (pattern = NULL ,
69+ fixed = FALSE ,
70+ invert = FALSE ,
71+ plots_only = TRUE ) {
72+ .list_module_functions(
73+ .module = " mcmc" ,
74+ .pattern = pattern ,
75+ fixed = fixed ,
76+ invert = invert ,
77+ plots_only = plots_only
78+ )
79+ }
3480
3581# ' @export
3682print.bayesplot_function_list <- function (x , ... ) {
@@ -48,10 +94,11 @@ print.bayesplot_function_list <- function(x, ...) {
4894
4995# internal ----------------------------------------------------------------
5096.list_module_functions <-
51- function (.module = c(" ppc" , " mcmc" ),
97+ function (.module = c(" ppc" , " ppd " , " mcmc" ),
5298 .pattern ,
5399 fixed = FALSE ,
54- invert = FALSE ) {
100+ invert = FALSE ,
101+ plots_only = TRUE ) {
55102
56103 .module <- match.arg(.module )
57104
@@ -62,6 +109,17 @@ print.bayesplot_function_list <- function(x, ...) {
62109 )
63110 return_funs <- sort(all_funs )
64111
112+ if (plots_only ) {
113+ # drop _data() functions
114+ return_funs <-
115+ grep(
116+ pattern = " _data()" ,
117+ x = return_funs ,
118+ invert = TRUE ,
119+ value = TRUE
120+ )
121+ }
122+
65123 if (! is.null(.pattern )) {
66124 return_funs <- grep(
67125 pattern = .pattern ,
@@ -71,6 +129,7 @@ print.bayesplot_function_list <- function(x, ...) {
71129 invert = invert
72130 )
73131 }
132+
74133 structure(
75134 return_funs ,
76135 class = c(" bayesplot_function_list" , " character" ),
0 commit comments