Open 1beb opened 3 years ago
Hey, I was able to trace this back to backend behavior. There are reasons that it works this way, but people agreed that it should be fixed, hopefully as we pay more attention to numeric variables with the incoming numeric arrays.
As a work-around, the "name" of the variable is included on the analysis page, so you can match it to the names of the dataset like so, to get back the aliases:
library(crunch)
# ds <- newExampleDataset()
ds <- loadDataset("Example dataset")
multitable <- newMultitable("~ `allpets`", ds)
r <- tabBook(multitable, dataset = ds[c("ndogs")])
# Instead of: aliases(r)
get_tabbook_aliases <- function(tabbook, dataset) {
var_info <- variables(dataset)
vapply(tabbook$meta$analyses, function(analysis) {
aliases(var_info[names(var_info) == analysis$name])
}, "")
}
get_tabbook_aliases(r, ds)
#> [1] "ndogs"
As the title specifies it appears that aliases returns as "total" for all NumericVariable type questions.
Here's a complete, but simple example:
In the example above the alias is not "total", it should be "ndogs"