Skip to content

Commit 1f1a81f

Browse files
authored
Whitespace variable trimming (#5)
* Add unlist() * Ensure beginning and ending of variable name is trimmed of whitespace * Add note
1 parent dc7b28d commit 1f1a81f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
- Improved graceful errors for `fetch_ucirepo()` and `list_available_datasets()`
66
when resources are not found/available. ([#3](https://github.com/coatless-rpkg/ucimlrepo/issues/3),
77
thanks Prof. Ripley!)
8+
9+
## Bug fixes
10+
11+
- Fixed internal subset issue with `fetch_ucirepo()` when metadata from the
12+
repository had whitespace characters in the variable names. ([#2](https://github.com/coatless-rpkg/ucimlrepo/issues/2))
813

914
# ucimlrepo 0.0.1
1015

R/fetch-ucirepo.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ fetch_ucirepo <- function(name, id) {
246246
stop('Role must be one of "ID", "Feature", "Target", or "Other"')
247247
}
248248

249-
variables_by_role[[variable$role]] <- c(variables_by_role[[variable$role]], variable$name)
249+
variables_by_role[[variable$role]] <- c(variables_by_role[[variable$role]], trimws(variable$name))
250250
}
251251

252252
# Extract dataframes for each variable role
253-
ids_df <- if (length(variables_by_role$ID) > 0) df[ , variables_by_role$ID, drop = FALSE] else NULL
253+
ids_df <- if (length(variables_by_role$ID) > 0) df[ , unlist(variables_by_role$ID), drop = FALSE] else NULL
254254
features_df <- if (length(variables_by_role$Feature) > 0) df[ , unlist(variables_by_role$Feature), drop = FALSE] else NULL
255255
targets_df <- if (length(variables_by_role$Target) > 0) df[ , unlist(variables_by_role$Target), drop = FALSE] else NULL
256256

0 commit comments

Comments
 (0)