This check fails for my dataset:
|
# Check that there is a id and weight for every table |
|
if (length(data) != length(id_cols)) { |
|
stop("Each table in data must have a corresponding id in id_cols") |
|
} |
|
|
|
if (weighted) { |
|
if (length(data) != length(wt_cols)) { |
|
stop("Each table in data must have a corresponding weight in wt_cols") |
|
} |
|
} |
The check should not look at the length of the id columns, but rather that each table in hts_data has an id in id_cols.
Something like:
missing_ids = lapply(hts_data, function(x) length(names(x)[names(x) %in% id_cols])==0)
any(unlist(missing_ids))
missing_wts = lapply(hts_data, function(x) length(names(x)[names(x) %in% wt_cols])==0)
any(unlist(missing_wts ))
This check fails for my dataset:
travelSurveyTools/R/hts_prep_variable.R
Lines 93 to 102 in bf48868
The check should not look at the length of the id columns, but rather that each table in hts_data has an id in id_cols.
Something like: