@@ -7,8 +7,12 @@ alluvialOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
77 public = list (
88 initialize = function (
99 vars = NULL ,
10+ condensationvar = NULL ,
1011 excl = TRUE ,
11- marg = FALSE , ... ) {
12+ marg = FALSE ,
13+ verb = FALSE ,
14+ fill = " first_variable" ,
15+ bin = " default" , ... ) {
1216
1317 super $ initialize(
1418 package = ' ClinicoPath' ,
@@ -19,6 +23,9 @@ alluvialOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
1923 private $ ..vars <- jmvcore :: OptionVariables $ new(
2024 " vars" ,
2125 vars )
26+ private $ ..condensationvar <- jmvcore :: OptionVariable $ new(
27+ " condensationvar" ,
28+ condensationvar )
2229 private $ ..excl <- jmvcore :: OptionBool $ new(
2330 " excl" ,
2431 excl ,
@@ -27,26 +34,62 @@ alluvialOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
2734 " marg" ,
2835 marg ,
2936 default = FALSE )
37+ private $ ..verb <- jmvcore :: OptionBool $ new(
38+ " verb" ,
39+ verb ,
40+ default = FALSE )
41+ private $ ..fill <- jmvcore :: OptionList $ new(
42+ " fill" ,
43+ fill ,
44+ options = list (
45+ " first_variable" ,
46+ " last_variable" ,
47+ " all_flows" ,
48+ " values" ),
49+ default = " first_variable" )
50+ private $ ..bin <- jmvcore :: OptionList $ new(
51+ " bin" ,
52+ bin ,
53+ options = list (
54+ " default" ,
55+ " mean" ,
56+ " median" ,
57+ " min_max" ,
58+ " cuts" ),
59+ default = " default" )
3060
3161 self $ .addOption(private $ ..vars )
62+ self $ .addOption(private $ ..condensationvar )
3263 self $ .addOption(private $ ..excl )
3364 self $ .addOption(private $ ..marg )
65+ self $ .addOption(private $ ..verb )
66+ self $ .addOption(private $ ..fill )
67+ self $ .addOption(private $ ..bin )
3468 }),
3569 active = list (
3670 vars = function () private $ ..vars $ value ,
71+ condensationvar = function () private $ ..condensationvar $ value ,
3772 excl = function () private $ ..excl $ value ,
38- marg = function () private $ ..marg $ value ),
73+ marg = function () private $ ..marg $ value ,
74+ verb = function () private $ ..verb $ value ,
75+ fill = function () private $ ..fill $ value ,
76+ bin = function () private $ ..bin $ value ),
3977 private = list (
4078 ..vars = NA ,
79+ ..condensationvar = NA ,
4180 ..excl = NA ,
42- ..marg = NA )
81+ ..marg = NA ,
82+ ..verb = NA ,
83+ ..fill = NA ,
84+ ..bin = NA )
4385)
4486
4587alluvialResults <- if (requireNamespace(' jmvcore' )) R6 :: R6Class(
4688 inherit = jmvcore :: Group ,
4789 active = list (
4890 todo = function () private $ .items [[" todo" ]],
49- plot = function () private $ .items [[" plot" ]]),
91+ plot = function () private $ .items [[" plot" ]],
92+ plot2 = function () private $ .items [[" plot2" ]]),
5093 private = list (),
5194 public = list (
5295 initialize = function (options ) {
@@ -64,7 +107,9 @@ alluvialResults <- if (requireNamespace('jmvcore')) R6::R6Class(
64107 " vars" ,
65108 " excl" ,
66109 " marg" ,
67- " inter" )))
110+ " verb" ,
111+ " fill" ,
112+ " bin" )))
68113 self $ add(jmvcore :: Image $ new(
69114 options = options ,
70115 title = " Alluvial Diagrams" ,
@@ -77,7 +122,20 @@ alluvialResults <- if (requireNamespace('jmvcore')) R6::R6Class(
77122 " vars" ,
78123 " excl" ,
79124 " marg" ,
80- " inter" )))}))
125+ " verb" ,
126+ " fill" ,
127+ " bin" )))
128+ self $ add(jmvcore :: Image $ new(
129+ options = options ,
130+ title = " `Condensation Plot ${condensationvar}`" ,
131+ name = " plot2" ,
132+ width = 600 ,
133+ height = 450 ,
134+ renderFun = " .plot2" ,
135+ requiresData = TRUE ,
136+ clearWith = list (
137+ " condensationvar" ),
138+ visible = " (condensationvar)" ))}))
81139
82140alluvialBase <- if (requireNamespace(' jmvcore' )) R6 :: R6Class(
83141 " alluvialBase" ,
@@ -105,35 +163,51 @@ alluvialBase <- if (requireNamespace('jmvcore')) R6::R6Class(
105163# ' @param data The data as a data frame.
106164# ' @param vars a string naming the variables from \code{data} that contains
107165# ' the values used for the Alluvial Diagram.
166+ # ' @param condensationvar The primary variable to be used for condensation.
108167# ' @param excl .
109168# ' @param marg .
169+ # ' @param verb .
170+ # ' @param fill A list for the argument fill for selecting the variable to be
171+ # ' represented by color. Default is 'first_variable'.
172+ # ' @param bin labels for the bins from low to high
110173# ' @return A results object containing:
111174# ' \tabular{llllll}{
112175# ' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
113176# ' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
177+ # ' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
114178# ' }
115179# '
116180# ' @export
117181alluvial <- function (
118182 data ,
119183 vars ,
184+ condensationvar ,
120185 excl = TRUE ,
121- marg = FALSE ) {
186+ marg = FALSE ,
187+ verb = FALSE ,
188+ fill = " first_variable" ,
189+ bin = " default" ) {
122190
123191 if ( ! requireNamespace(' jmvcore' ))
124192 stop(' alluvial requires jmvcore to be installed (restart may be required)' )
125193
126194 if ( ! missing(vars )) vars <- jmvcore :: resolveQuo(jmvcore :: enquo(vars ))
195+ if ( ! missing(condensationvar )) condensationvar <- jmvcore :: resolveQuo(jmvcore :: enquo(condensationvar ))
127196 if (missing(data ))
128197 data <- jmvcore :: marshalData(
129198 parent.frame(),
130- `if`( ! missing(vars ), vars , NULL ))
199+ `if`( ! missing(vars ), vars , NULL ),
200+ `if`( ! missing(condensationvar ), condensationvar , NULL ))
131201
132202
133203 options <- alluvialOptions $ new(
134204 vars = vars ,
205+ condensationvar = condensationvar ,
135206 excl = excl ,
136- marg = marg )
207+ marg = marg ,
208+ verb = verb ,
209+ fill = fill ,
210+ bin = bin )
137211
138212 analysis <- alluvialClass $ new(
139213 options = options ,
0 commit comments