Skip to content

Commit

Permalink
read_vc() returns the variable descriptions as attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Aug 24, 2024
1 parent 5787cd7 commit acdaf5c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions R/read_vc.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,30 @@ read_vc.character <- function(file, root = ".") {
details = details, optimize = optimize
)

names(file) <-
c(
names(file) <- c(
meta_data[["..generic"]][["data_hash"]],
meta_data[["..generic"]][["hash"]]
)
attr(raw_data, "source") <- file

has_description <- vapply(
details, FUN.VALUE = logical(1),
FUN = function(x) {
"description" %in% names(x)
}
)
has_description <- names(has_description)[has_description]
if (length(has_description) > 0) {
for (desc in has_description) {
attr(raw_data[[desc]], "description") <- details[[desc]]$description

Check warning on line 145 in R/read_vc.R

View check run for this annotation

Codecov / codecov/patch

R/read_vc.R#L144-L145

Added lines #L144 - L145 were not covered by tests
}
}

return(raw_data)
}



reinstate <- function(raw_data, col_names, col_classes, details, optimize) {
# reinstate factors
for (id in col_names[col_classes == "factor"]) {
Expand Down

0 comments on commit acdaf5c

Please sign in to comment.