Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions R/csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,15 @@ remaining_columns_to_read <- function(requested, currently_read, all) {
unread <- requested[!(requested %in% currently_read)]
} else {
all_remaining <- all[!(all %in% currently_read)]
unread <- c()
for (p in requested) {
if (any(all_remaining == p)) {
unread <- c(unread, p)
}
is_unread_element <- startsWith(all_remaining, paste0(p, "["))
if (any(is_unread_element)) {
unread <- c(unread, all_remaining[is_unread_element])
}
# identify exact matches
matched <- as.list(match(requested, all_remaining))
# loop over requests not exactly matched
for (id in which(is.na(matched))) {
matched[[id]] <-
which(startsWith(all_remaining, paste0(requested[id], "[")))
}
# collect all unread variables
unread <- all_remaining[unlist(matched)]
}
if (length(unread)) {
unique(unread)
Expand Down
23 changes: 12 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ is_verbose_mode <- function() {

# used in both fit.R and csv.R for variable filtering
matching_variables <- function(variable_filters, variables) {
not_found <- c()
selected_variables <- c()
for (v in variable_filters) {
selected <- variables == v | startsWith(variables, paste0(v, "["))
selected_variables <- c(selected_variables, variables[selected])
variables <- variables[!selected]
if (!any(selected)) {
not_found <- c(not_found, v)
}
}
# identify exact matches
matched <- as.list(match(variable_filters, variables))
# loop over filters not exactly matched
for (id in which(is.na(matched))) {
# assign all variable names that match the filter as an array
matched[[id]] <-
which(startsWith(variables, paste0(variable_filters[id], "[")))
}
# collect all selected variables
selected_variables <- variables[unlist(matched)]
# collect all filters not found
not_found <- variable_filters[vapply(matched, length, 0L) == 0]
list(
matching = selected_variables,
not_found = not_found
)
}


# checks for OS and hardware ----------------------------------------------

os_is_windows <- function() {
Expand Down