Skip to content

Non-natural-number indicators #2

@ramanshah

Description

@ramanshah

@andburch:

I also noticed that the INDICATOR TOML only has a description, and NA level, and the labels. I assume this means that it expects indicator data to come in integer values?

I think that's correct. The current prototype code seems to embed an assumption that the indicator is natively 1, 2, ..., N, or blank in the input CSV survey dump. That's a bad assumption.

tabulate_univariate_segmentation <- function(data, spec, seg, ind) {
  seg_spec <- spec[["segments"]][[seg]]
  ind_spec <- spec[["indicators"]][[ind]]

  ind_prep <- paste0(ind, "_prep")
  seg_prep <- paste0(seg, "_prep")

  summary_nonblank <- data[!is.na(get(ind_prep)),
                           .(avg_nonblank=mean(get(ind_prep)), num_nonblank=.N), # <-- Depends on ind_prep being NA, 1, 2, ..., N
                           by=.(x=get(seg_prep))]
  summary_blank <- data[is.na(get(ind_prep)), .(num_blank=.N), by=.(x=get(seg_prep))]

  result <- data.table(x=unique(c(seg_spec$output_levels,
                                  seg_spec$na_level)))
  result[summary_nonblank, avg_nonblank := avg_nonblank, on=.(x)]
  result[summary_nonblank, num_nonblank := num_nonblank, on=.(x)]
  result[summary_blank, num_blank := num_blank, on=.(x)]
  result[is.na(num_nonblank), num_nonblank := 0]
  result[is.na(num_blank), num_blank := 0]

  result
}

Our chosen open-data testbed (the StackOverflow survey) breaks this. It does the (very common) thing of having plain English strings for responses instead of numerical Likert levels. We need to enhance the TOML spec and downstream munging/tabulating logic to shim out the responses and translate them from stuff like "1 - Strongly Disagree" to something like a numeric 1 which is amenable to downstream math.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions