@@ -7,7 +7,7 @@ check_missing_data <- function(x, y, fn = "some function", verbose = FALSE) {
77 cl_chr <- as.character()
88 msg <- paste0(fn , " () removed " , sum(! compl_data ), " rows of " ,
99 " data due to missing values." )
10- rlang :: warn (msg )
10+ cli :: cli_warn (msg )
1111 }
1212 }
1313 list (x = x , y = y )
@@ -18,14 +18,14 @@ check_data_att <- function(x, y) {
1818
1919 # check matrices/vectors, matrix type, matrix column names
2020 if (! is.matrix(x ) || ! is.numeric(x )) {
21- rlang :: abort (" 'x' should be a numeric matrix." )
21+ cli :: cli_abort (" 'x' should be a numeric matrix." )
2222 }
2323 nms <- colnames(x )
2424 if (length(nms ) != ncol(x )) {
25- rlang :: abort (" Every column of 'x' should have a name." )
25+ cli :: cli_abort (" Every column of 'x' should have a name." )
2626 }
2727 if (! is.vector(y ) & ! is.factor(y )) {
28- rlang :: abort (" 'y' should be a vector." )
28+ cli :: cli_abort (" 'y' should be a vector." )
2929 }
3030 invisible (NULL )
3131}
@@ -87,12 +87,12 @@ check_integer <-
8787
8888 if (! is.integer(x )) {
8989 msg <- paste(format_msg(fn , arg ), " to be integer." )
90- rlang :: abort (msg )
90+ cli :: cli_abort (msg )
9191 }
9292
9393 if (single && length(x ) > 1 ) {
9494 msg <- paste(format_msg(fn , arg ), " to be a single integer." )
95- rlang :: abort (msg )
95+ cli :: cli_abort (msg )
9696 }
9797
9898 out_of_range <- check_rng(x , x_min , x_max , incl )
@@ -101,7 +101,7 @@ check_integer <-
101101 " to be an integer on " ,
102102 ifelse(incl [[1 ]], " [" , " (" ), x_min , " , " ,
103103 x_max , ifelse(incl [[2 ]], " ]" , " )" ), " ." )
104- rlang :: abort (msg )
104+ cli :: cli_abort (msg )
105105 }
106106
107107 invisible (TRUE )
@@ -116,12 +116,12 @@ check_double <- function(x,
116116
117117 if (! is.double(x )) {
118118 msg <- paste(format_msg(fn , arg ), " to be a double." )
119- rlang :: abort (msg )
119+ cli :: cli_abort (msg )
120120 }
121121
122122 if (single && length(x ) > 1 ) {
123123 msg <- paste(format_msg(fn , arg ), " to be a single double." )
124- rlang :: abort (msg )
124+ cli :: cli_abort (msg )
125125 }
126126
127127 out_of_range <- check_rng(x , x_min , x_max , incl )
@@ -130,7 +130,7 @@ check_double <- function(x,
130130 " to be a double on " ,
131131 ifelse(incl [[1 ]], " [" , " (" ), x_min , " , " ,
132132 x_max , ifelse(incl [[2 ]], " ]" , " )" ), " ." )
133- rlang :: abort (msg )
133+ cli :: cli_abort (msg )
134134 }
135135
136136 invisible (TRUE )
@@ -142,18 +142,18 @@ check_character <- function(x, single = TRUE, vals = NULL, fn = NULL) {
142142
143143 if (! is.character(x )) {
144144 msg <- paste(format_msg(fn , arg ), " to be character." )
145- rlang :: abort (msg )
145+ cli :: cli_abort (msg )
146146 }
147147
148148 if (single && length(x ) > 1 ) {
149149 msg <- paste(format_msg(fn , arg ), " to be a single character string." )
150- rlang :: abort (msg )
150+ cli :: cli_abort (msg )
151151 }
152152
153153 if (! is.null(vals )) {
154154 if (any(! (x %in% vals ))) {
155155 msg <- paste0(format_msg(fn , arg ), " contains an incorrect value." )
156- rlang :: abort (msg )
156+ cli :: cli_abort (msg )
157157 }
158158 }
159159
@@ -166,12 +166,12 @@ check_logical <- function(x, single = TRUE, fn = NULL) {
166166
167167 if (! is.logical(x )) {
168168 msg <- paste(format_msg(fn , arg ), " to be logical." )
169- rlang :: abort (msg )
169+ cli :: cli_abort (msg )
170170 }
171171
172172 if (single && length(x ) > 1 ) {
173173 msg <- paste(format_msg(fn , arg ), " to be a single logical." )
174- rlang :: abort (msg )
174+ cli :: cli_abort (msg )
175175 }
176176 invisible (TRUE )
177177}
@@ -188,7 +188,7 @@ check_class_weights <- function(wts, lvls, xtab, fn) {
188188 }
189189 if (! is.numeric(wts )) {
190190 msg <- paste(format_msg(fn , " class_weights" ), " to a numeric vector" )
191- rlang :: abort (msg )
191+ cli :: cli_abort (msg )
192192 }
193193
194194 if (length(wts ) == 1 ) {
@@ -202,6 +202,7 @@ check_class_weights <- function(wts, lvls, xtab, fn) {
202202 if (length(lvls ) != length(wts )) {
203203 msg <- paste0(" There were " , length(wts ), " class weights given but " ,
204204 length(lvls ), " were expected." )
205+ cli :: cli_abort(msg )
205206 }
206207
207208 nms <- names(wts )
@@ -211,7 +212,7 @@ check_class_weights <- function(wts, lvls, xtab, fn) {
211212 if (! identical(sort(nms ), sort(lvls ))) {
212213 msg <- paste(" Names for class weights should be:" ,
213214 paste0(" '" , lvls , " '" , collapse = " , " ))
214- rlang :: abort (msg )
215+ cli :: cli_abort (msg )
215216 }
216217 wts <- wts [lvls ]
217218 }
0 commit comments