alteryx / AlteryxPredictive

This is an R package containing utility functions used by the predictive tools in Alteryx.
GNU General Public License v3.0
15 stars 15 forks source link

write out empty plots to fill metainfo. #76

Closed ramnathv closed 7 years ago

ramnathv commented 7 years ago

This PR writes out empty plots for Outputs 4 and 5 when Regularization is set to FALSE. This allows MetaInfo to be written out for these outputs, thereby preventing the infamous ugly red mark on opening a workflow.

There are only two cardinal rules to follow with R tools to avoid MetaInfo issues:

  1. The R tool should always write all outputs no matter how the macro is configured
  2. The R tool should always write outputs with field names that stay unchanged no matter how the macro is configured.

While this may seem impossible to achieve at first glance, there are tricks that allow one to satisfy both (1) and (2).

The first rule can always be satisfied by writing out empty plots or data. If they affect anything downstream, you can always use Alteryx tools to filter or strip things out. Alteryx tools handle metainfo updates a lot better and so you are always better of relegating that to Alteryx tools.

The second rule seems unattainable since there are several use cases where outputs coming out of the R tool need to have dynamic field names. Here again, there are two tricks one can use:

  1. When the number of fields are fixed, use placeholder field names for outputs created by the R tool and use a Dynamic Rename downstream to update them to what they should be.

  2. When the number of fields in an output is dynamic, consider rewriting the logic to produce long data with fixed number of columns instead of wide data. Use the CrossTab tool downstream to coerce the data back to the desired structure.