@@ -18,23 +18,24 @@ is_verbose_mode <- function() {
18
18
19
19
# used in both fit.R and csv.R for variable filtering
20
20
matching_variables <- function (variable_filters , variables ) {
21
- not_found <- c()
22
- selected_variables <- c()
23
- for (v in variable_filters ) {
24
- selected <- variables == v | startsWith(variables , paste0(v , " [" ))
25
- selected_variables <- c(selected_variables , variables [selected ])
26
- variables <- variables [! selected ]
27
- if (! any(selected )) {
28
- not_found <- c(not_found , v )
29
- }
30
- }
21
+ # identify exact matches
22
+ matched <- as.list(match(variable_filters , variables ))
23
+ # loop over filters not exactly matched
24
+ for (id in which(is.na(matched ))) {
25
+ # assign all variable names that match the filter as an array
26
+ matched [[id ]] <-
27
+ which(startsWith(variables , paste0(variable_filters [id ], " [" )))
28
+ }
29
+ # collect all selected variables
30
+ selected_variables <- variables [unlist(matched )]
31
+ # collect all filters not found
32
+ not_found <- variable_filters [vapply(matched , length , 0L ) == 0 ]
31
33
list (
32
34
matching = selected_variables ,
33
35
not_found = not_found
34
36
)
35
37
}
36
38
37
-
38
39
# checks for OS and hardware ----------------------------------------------
39
40
40
41
os_is_windows <- function () {
0 commit comments