30
30
# '
31
31
# ' @template return-ggplot
32
32
# '
33
- # ' @details For all of these plots \code{y} and \code{yrep} must be
34
- # ' integers, although they need not be integers in the strict sense
35
- # ' of \R's \code{\link{integer}} type. For rootogram plots \code{y}
33
+ # ' @details For all of these plots \code{y} and \code{yrep} must be
34
+ # ' integers, although they need not be integers in the strict sense
35
+ # ' of \R's \code{\link{integer}} type. For rootogram plots \code{y}
36
36
# ' and \code{yrep} must also be non-negative.
37
37
# '
38
38
# ' @section Plot Descriptions:
@@ -101,28 +101,37 @@ ppc_bars <-
101
101
fatten = 3 ,
102
102
freq = TRUE ) {
103
103
104
- check_ignored_arguments(... )
105
- y <- validate_y(y )
106
- yrep <- validate_yrep(yrep , y )
107
- if (! all_whole_number(y ))
108
- stop(" ppc_bars expects 'y' to be discrete." )
109
- if (! all_whole_number(yrep ))
110
- stop(" ppc_bars expects 'yrep' to be discrete." )
111
-
112
- alpha <- (1 - prob ) / 2
113
- probs <- sort(c(alpha , 0.5 , 1 - alpha ))
114
- yrep_data <- ppc_bars_yrep_data(y , yrep , probs = probs , freq = freq , group = NULL )
115
- .ppc_bars(
116
- y_data = data.frame (y = y ),
117
- yrep_data ,
118
- grouped = FALSE ,
119
- facet_args = list (),
120
- width = width ,
121
- size = size ,
122
- fatten = fatten ,
123
- freq = freq
124
- )
104
+ check_ignored_arguments(... )
105
+ y <- validate_y(y )
106
+ yrep <- validate_yrep(yrep , y )
107
+ if (! all_whole_number(y )) {
108
+ stop(" ppc_bars expects 'y' to be discrete." )
125
109
}
110
+ if (! all_whole_number(yrep )) {
111
+ stop(" ppc_bars expects 'yrep' to be discrete." )
112
+ }
113
+
114
+ alpha <- (1 - prob ) / 2
115
+ probs <- sort(c(alpha , 0.5 , 1 - alpha ))
116
+ yrep_data <- ppc_bars_yrep_data(
117
+ y ,
118
+ yrep ,
119
+ probs = probs ,
120
+ freq = freq ,
121
+ group = NULL
122
+ )
123
+
124
+ .ppc_bars(
125
+ y_data = data.frame (y = y ),
126
+ yrep_data ,
127
+ grouped = FALSE ,
128
+ facet_args = list (),
129
+ width = width ,
130
+ size = size ,
131
+ fatten = fatten ,
132
+ freq = freq
133
+ )
134
+ }
126
135
127
136
128
137
# ' @rdname PPC-discrete
@@ -142,29 +151,31 @@ ppc_bars_grouped <-
142
151
fatten = 3 ,
143
152
freq = TRUE ) {
144
153
145
- check_ignored_arguments(... )
146
- y <- validate_y(y )
147
- yrep <- validate_yrep(yrep , y )
148
- group <- validate_group(group , y )
149
- if (! all_whole_number(y ))
150
- stop(" ppc_bars_grouped expects 'y' to be discrete." )
151
- if (! all_whole_number(yrep ))
152
- stop(" ppc_bars_grouped expects 'yrep' to be discrete." )
153
-
154
- alpha <- (1 - prob ) / 2
155
- probs <- sort(c(alpha , 0.5 , 1 - alpha ))
156
- yrep_data <- ppc_bars_yrep_data(y , yrep , probs , freq = freq , group = group )
157
- .ppc_bars(
158
- y_data = data.frame (y , group ),
159
- yrep_data ,
160
- grouped = TRUE ,
161
- facet_args = facet_args ,
162
- width = width ,
163
- size = size ,
164
- fatten = fatten ,
165
- freq = freq
166
- )
154
+ check_ignored_arguments(... )
155
+ y <- validate_y(y )
156
+ yrep <- validate_yrep(yrep , y )
157
+ group <- validate_group(group , y )
158
+ if (! all_whole_number(y )) {
159
+ stop(" ppc_bars_grouped expects 'y' to be discrete." )
167
160
}
161
+ if (! all_whole_number(yrep )) {
162
+ stop(" ppc_bars_grouped expects 'yrep' to be discrete." )
163
+ }
164
+
165
+ alpha <- (1 - prob ) / 2
166
+ probs <- sort(c(alpha , 0.5 , 1 - alpha ))
167
+ yrep_data <- ppc_bars_yrep_data(y , yrep , probs , freq = freq , group = group )
168
+ .ppc_bars(
169
+ y_data = data.frame (y , group ),
170
+ yrep_data ,
171
+ grouped = TRUE ,
172
+ facet_args = facet_args ,
173
+ width = width ,
174
+ size = size ,
175
+ fatten = fatten ,
176
+ freq = freq
177
+ )
178
+ }
168
179
169
180
170
181
# ' @rdname PPC-discrete
0 commit comments