takeAction method

void takeAction()

Implementation

void takeAction() {
  // Run the R scripts.

  if (selectedTransform == 'Constant' && ref.read(imputedProvider) == '') {
    showOk(
      context: context,
      title: 'No Constant Value',
      content: '''

          To impute missing data to a constant value for this variable you
          need to specify the constant value. Please provide a Constant and
          try again.

          ''',
    );
  } else {
    switch (selectedTransform) {
      case 'Mean':
        // Check if the variable is numeric before running the R script.
        // If it is categoric, show an error message.
        if (ref.read(typesProvider)[selected] == Type.categoric) {
          selectedTransform = 'Mode';
        } else {
          rSource(context, ref, ['transform_impute_mean_numeric']);
        }

      case 'Median':
        // Check if the variable is numeric before running the R script.
        // If it is categoric, show an error message.
        if (ref.read(typesProvider)[selected] == Type.categoric) {
          selectedTransform = 'Mode';
        } else {
          rSource(context, ref, ['transform_impute_median_numeric']);
        }

      case 'Mode':
        rSource(context, ref, ['transform_impute_mode']);
      case 'Constant':
        rSource(context, ref, ['transform_impute_constant']);
      default:
        showUnderConstruction(context);
    }
  }
}