/
deprecated.R
186 lines (175 loc) · 4.03 KB
/
deprecated.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#' Deprecated functions
#'
#'
#' Deprecated `chk_()` functions.
#'
#' @family deprecated
#'
#' @inheritParams chk_flag
#' @keywords internal
#' @name chk_deprecated
NULL
#' @describeIn chk_deprecated Check Directories Exist
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace with `[chk_all](x, [chk_dir])`
#'
#' @export
chk_dirs <- function(x) {
deprecate_warn("0.2.0",
what = "chk::chk_dirs()",
details = "Please use `chk_all(x, chk_dir)` instead"
)
chk_all(x, chk_dir)
}
#' @describeIn chk_deprecated Check Files Exist
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace with `[chk_all](x, [chk_file])`
#'
#' @export
chk_files <- function(x) {
deprecate_warn("0.2.0",
what = "chk::chk_files()",
details = "Please use `chk_all(x, chk_file)` instead"
)
chk_all(x, chk_file)
}
#' @describeIn chk_deprecated Check Has
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace by [chk_superset()]
#'
#' @export
chk_has <- function(x, values, x_name = NULL) {
if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x))
chk_superset(x, values, x_name = x_name)
deprecate_warn("0.2.0",
what = "chk::chk_has()",
with = "chk::chk_superset()"
)
invisible()
}
#' @describeIn chk_deprecated Check In
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace by [chk_subset()]
#'
#' @export
chk_in <- function(x, values, x_name = NULL) {
if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x))
chk_subset(x, values, x_name = x_name)
deprecate_warn("0.2.0",
what = "chk::chk_in()",
with = "chk::chk_subset()"
)
invisible()
}
#' @describeIn chk_deprecated Check No Missing Values
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace with [chk_not_any_na()]
#'
#' @export
chk_no_missing <- function(x, x_name = NULL) {
deprecate_warn("0.2.0",
what = "chk::chk_no_missing()", with = "chk::chk_not_any_na()",
id = "chk_no_missing"
)
if (vld_no_missing(x)) {
return(invisible())
}
if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x))
abort_chk(x_name, " must not have missing values", x = x)
}
#' @describeIn chk_deprecated Validate No Missing Values
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace with [vld_not_any_na()]
#'
#' @export
vld_no_missing <- function(x) {
deprecate_warn("0.2.0",
what = "chk::vld_no_missing()", with = "chk::vld_not_any_na()",
id = "chk_no_missing"
)
!anyNA(x)
}
#' @describeIn chk_deprecated Turns checking off
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This approach is no longer recommended
#'
#' @export
chk_off <- function() {
deprecate_stop("0.2.0",
what = "chk::chk_off()",
details = "This approach is no longer recommended"
)
options(chk.on = FALSE)
}
#' @describeIn chk_deprecated Turns checking on
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This approach is no longer recommended
#'
#' @export
chk_on <- function() {
deprecate_stop("0.2.0",
what = "chk::chk_on()",
details = "This approach is no longer recommended"
)
options(chk.on = TRUE)
}
#' @describeIn chk_deprecated Tests checking on
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This approach is no longer recommended
#'
#' @export
is_chk_on <- function() {
deprecate_stop("0.2.0",
what = "chk::is_chk_on()",
details = "This approach is no longer recommended"
)
getOption("chk.on", TRUE)
}
#' @describeIn chk_deprecated Check Proportion
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace by `[chk_number](x); [chk_range](x)`
#'
#' @export
chk_proportion <- function(x, x_name = NULL) {
deprecate_warn("0.2.0",
what = "chk::chk_proportion()",
details = "Please use `chk_number(x)` or `chk_range(x)` instead"
)
if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x))
chk_number(x)
chk_range(x)
}
#' @describeIn chk_deprecated Deparse Backtick
#'
#' `r lifecycle::badge("deprecated")`
#'
#' Replace with [deparse_backtick_chk()]
#'
#' @export
deparse_backtick <- function(x) {
deprecate_warn("0.2.0",
what = "chk::deparse_backtick()",
with = "chk::deparse_backtick_chk()"
)
deparse_backtick_chk(x)
}