#' Get a list of active funds.
#'
#' \code{getActiveFunds} returns active funds in a named vector with funds' IDs
#' and funds' names as the names of the vector.
#'
#' @export
#' @import dplyr
#'
#' @param fundsSummary data frame with fund names, IDs, and dates of last
#' observations. Ideally, output of the \code{\link{getFundsSummary}}
#' function.
#' @param inactiveAfter numeric, number of days after wich a fund is considered
#' inactive.
#'
#' @return Named vector with funds' IDs as values and funds' names as the names
#' of the vector.
getActiveFunds <- function(fundsSummary, inactiveAfter = 30) {
# fundsNav <- getFundData(file = "fund-data-2016-12-26.RData",
# dir = "../PensionFundsLvApp/data")
# fundsSummary <- getFundsSummary(fundsNav)
# Extract funds
fundsSummary %>%
filter((Sys.Date() - end) < inactiveAfter) %>%
select(id, name) ->
activeDf
# Create a named vector
activeVector <- activeDf$id
names(activeVector) <- activeDf$name
return(activeVector)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.