Skip to content

Interval support functions #379

@billdenney

Description

@billdenney

Based on the conversation in #371, we need a set of interval-support functions. Some of the needs are:

  • Drop some/all parameters being calculated (be sure that there is an option for exceptions for specific parameters)
  • Add parameters to calculate
  • Add or remove imputation

The initial interface that I'm thinking of is:

All functions

The data input argument can be either

  • a data.frame that specifies the intervals
  • A PKNCAdata object (or something that can be coerced into a PKNCAdata object)

Drop parameters

interval_remove_param(data, param = NULL, param_pattern = NULL)

  • param is a character vector of parameters to remove
  • param_pattern is a character vector (can be more than one pattern) of regular expression patterns of parameters to remove

One or both of param or param_pattern must be given.

Sets all parameters matching param or param_pattern to TRUE.

Add param

It's not clear to me that this is necessary since you can simply set the column to TRUE. But, we can include it for completeness of the interface and the fact that it's trivial.

interval_add_param(data, param = NULL, param_pattern = NULL)

Arguments are the same as interval_remove_param().

Sets all parameters matching param or param_pattern to FALSE.

Add imputation

interval_add_impute(data, impute, after = Inf)

  • impute is the imputation character string to add, matching the behavior of PKNCAdata()
  • after follows similar behavior to the after argument of base::append(); 0 indicates it will be added as the first imputation method; Inf (or any number greater than the number of methods currently specified) indicates that it will be added as the last imputation method;

If there is already an imputation:

  • the imputation will be separated by commas (i.e. strsplit(current_impute, split = "[, ]"))
  • the new imputation will be added at the correct place (defined by after), and
  • The final imputation method will be put back together separated by commas (i.e. vapply(X = new_impute, FUN = paste, collapse = ",", FUN.VALUE = ""))

Remove imputation

interval_remove_impute(data, impute)

  • split any imputation from the intervals and remove it
  • warn if the imputation was not found in any of the intervals

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