cut_breaks_as_intervals {YAPSA} | R Documentation

## Wrapper for cut

### Description

In this wrapper function for the known `cut` function, the `breaks` vector need not be supplied directly, instead, for every break, an interval is supplied and the function optimizes the choice of the breakpoint by chosing a local minimum of the distribution.

### Usage

    cut_breaks_as_intervals(
      in_vector,
      in_outlier_cutoffs = c(0, 3000),
      in_cutoff_ranges_list = list(c(60, 69), c(25, 32)),
      in_labels = c("late", "intermediate", "early"),
      in_name = "",
      output_path = NULL
    )

### Arguments

`in_vector` | Vector of numerical continuously distributed input
`in_outlier_cutoffs` | Interval specifyinf the upper and lower bounds of the range to be considered
`in_cutoff_ranges_list` | List if intervals in which the cutoffs for `cut` have to be optimized.
`in_labels` | Labels assigned to the strata or factors returned
`in_name` | String specifying the name of the quantity analyzed (and plotted on the x-axis of the figure to be created).
`output_path` | Path where the figure produced by the density function should be stored if non-NULL.

### Value

A list with entries `category_vector`, and `density_plot` and `cutoffs`

- `category_vector`: Factor vector of the categories or strata, of the same length as `in_vector`

- `density_plot`: Density plot produced by the density function and indication of the chosen cutoffs.

- `cutoffs`: Vector of the computed optimal cutoffs

### See Also

`cut`

`density`

### Examples

     data(lymphoma_test)
     lymphoma_test_df$random_norm <- rnorm(dim(lymphoma_test_df)[1])
     temp_list <- cut_breaks_as_intervals(
       lymphoma_test_df$random_norm,
       in_outlier_cutoffs=c(-4,4),
       in_cutoff_ranges_list=list(c(-2.5,-1.5),c(0.5,1.5)),
       in_labels=c("small","intermediate","big"))
      temp_list$density_plot

[Package YAPSA version 1.18.0 Index]