| filter_top_n | R Documentation |
Most commonly used filter function. Selects top N (highest) or bottom N (lowest) stocks by signal value. Optimized for 5-10x faster performance.
filter_top_n(signal_df, n, ascending = FALSE)
signal_df |
Data frame with Date column and signal values |
n |
Number of stocks to select |
ascending |
FALSE (default) selects highest, TRUE selects lowest |
Binary selection matrix (1 = selected, 0 = not selected)
data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, 12)
# Select 10 highest momentum stocks
top_momentum <- filter_top_n(momentum, n = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.