View source: R/compute_breakpoints.R
compute_breakpoints | R Documentation |
This function computes breakpoints based on a specified sorting. It can optionally filter the data by exchanges before computing the breakpoints. The function requires either the number of portfolios to be created or specific percentiles for the breakpoints, but not both. The function also optionally handles cases where the sorting variable clusters on the edges, by assigning all extreme values to the edges and attempting to compute equally populated breakpoints with the remaining values.
compute_breakpoints(
data,
sorting_variable,
breakpoint_options,
data_options = NULL
)
data |
A data frame containing the dataset for breakpoint computation. |
sorting_variable |
A string specifying the column name in |
breakpoint_options |
A named list of breakpoint_options for the breakpoints. The arguments include
|
data_options |
A named list of data_options with characters, indicating the column names
required to run this function. The required column names identify dates. Defaults to |
A vector of breakpoints of the desired length.
This function will stop and throw an error if both n_portfolios
and
percentiles
are provided or if neither is provided. Ensure that you only
use one of these parameters.
data <- data.frame(
id = 1:100,
exchange = sample(c("NYSE", "NASDAQ"), 100, replace = TRUE),
market_cap = 1:100
)
compute_breakpoints(data, "market_cap", breakpoint_options(n_portfolios = 5))
compute_breakpoints(
data, "market_cap",
breakpoint_options(percentiles = c(0.2, 0.4, 0.6, 0.8), breakpoint_exchanges = c("NYSE"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.