shinysurveys icon indicating copy to clipboard operation
shinysurveys copied to clipboard

Feat: Show a dependency if a question is one (or more) of multiple values

Open jdtrat opened this issue 2 years ago • 4 comments

This is particularly relevant for extended input types (e.g., select inputs with multiple = TRUE; also see #43). Possible implementation allows for dependency_value column to have comma-separated values that get parsed internally. In showDependence() function, we could then change the == to be %in%:

https://github.com/jdtrat/shinysurveys/blob/1e4a5b08b7c63218bfd11654a96240c5d34538ed/R/utils_render-survey.R#L65

@mikmart and @jmbo1190 what do you think about this idea/implementation?

jdtrat avatar Apr 13 '22 14:04 jdtrat

sounds ok but not sure what would be a good case for this. any example in mind?

jbodart-argenx avatar Apr 13 '22 20:04 jbodart-argenx

My initial thought was it'd be nice to not have to parse anything and use a list-column for dependency_value instead. But making that backwards compatible would add complexity, and it wouldn't play well with defining surveys in external files (Excel etc.).

With parsing, there's a likely rare, but possibly very confusing, case where a string value meant as a single dependency happens to contain the multi-value delimiter.

And lastly, would any() be the correct predicate for checking multiple values? I suppose it's the only one that makes sense with single-valued questions, but for multiple values you might also want all() or more complex ways to combine answers.

I'd perhaps try to think about a more general approach to handling complex dependence relationships.

mikmart avatar Apr 17 '22 07:04 mikmart

All great points, @mikmart! I didn't think about the delimiter complexity but perhaps that could be a user-defined separation depending on their storage format (e.g., 'csv' and 'tsv' files could both use a | delimiter). Either way, I think this definitely requires a general approach and will give it some more thought.

@jbodart-argenx I'll see if I can think up a reprex (should've posted one initially, sorry about that!). Maybe @monitoringhsd has one?

jdtrat avatar Apr 21 '22 00:04 jdtrat

@jdtrat, I have tried to explain and provide an example for my current use case in #49, where the dependence variable should have up to three values of previous questions from input_id. Please let me know if more details are needed.

monitoringhsd avatar Apr 21 '22 11:04 monitoringhsd