@@ -1183,9 +1183,39 @@ filler_contrasts <- function(x, how.many = nlevels(x), rescale = TRUE) {
1183
1183
# ' @describeIn filler_contrasts Return indices of filler contrasts
1184
1184
# ' @export
1185
1185
which_filler <- function (x ) {
1186
- if (! inherits(x , " hypr" )) stop(" `x` must be a hypr object!" )
1187
- if (! is.null(attr(x @ cmat , " which_fillers" ))) return (attr(x @ cmat , " which_fillers" ))
1188
- integer(0 )
1186
+ if (inherits(x , " hypr" ) || inherits(x , " hypr_cmat" )) {
1187
+ cm <- if (inherits(x , " hypr" )) cmat(x , add_intercept = FALSE , remove_intercept = FALSE ) else x
1188
+ if (! is.null(attr(cm , " which_fillers" ))) return (attr(cm , " which_fillers" ))
1189
+ integer(0 )
1190
+ } else stop(" `x` must be a hypr object or hypr cmat!" )
1191
+ }
1192
+
1193
+ # ' @describeIn filler_contrasts Return indices of filler contrasts
1194
+ # ' @export
1195
+ which_target <- function (x ) {
1196
+ if (inherits(x , " hypr" ) || inherits(x , " hypr_cmat" )) {
1197
+ cm <- if (inherits(x , " hypr" )) cmat(x , add_intercept = FALSE , remove_intercept = FALSE ) else x
1198
+ setdiff(seq_len(ncol(cm )), which_filler(cm ))
1199
+ } else stop(" `x` must be a hypr object or hypr cmat!" )
1200
+ }
1201
+
1202
+
1203
+ # ' @describeIn filler_contrasts Return names of filler contrasts
1204
+ # ' @export
1205
+ filler_names <- function (x ) {
1206
+ if (inherits(x , " hypr" ) || inherits(x , " hypr_cmat" )) {
1207
+ cm <- if (inherits(x , " hypr" )) cmat(x , add_intercept = FALSE , remove_intercept = FALSE ) else x
1208
+ colnames(cm )[which_filler(cm )]
1209
+ } else stop(" `x` must be a hypr object or hypr cmat!" )
1210
+ }
1211
+
1212
+ # ' @describeIn filler_contrasts Return names of target contrasts
1213
+ # ' @export
1214
+ target_names <- function (x ) {
1215
+ if (inherits(x , " hypr" ) || inherits(x , " hypr_cmat" )) {
1216
+ cm <- if (inherits(x , " hypr" )) cmat(x , add_intercept = FALSE , remove_intercept = FALSE ) else x
1217
+ colnames(cm )[- which_filler(cm )]
1218
+ } else stop(" `x` must be a hypr object or hypr cmat!" )
1189
1219
}
1190
1220
1191
1221
0 commit comments