Skip to content

In getDividends have option to not append .div to the column name #369

Open
@ggrothendieck

Description

Currently getDividends is hard coded to append .div to the column name. Would like to be able to specify name. Maybe name = "%s.div" if you wanted it and that could be the default or "%s" if not or "div" if you wanted name to be literally div.

In that case this could be simplified:

library(dplyr);
library(quantmod);
library(purrr);
library(tools);
stocks <- c("AAPL", "MMM", "CAT", "MSFT", "TSLA");

map_dfr(stocks, \(x) getDividends(x) |> 
                     fortify.zoo(melt  = TRUE, names = c("date", "name", "div")) |>
                     tail(2) |>
                     mutate(name = file_path_sans_ext(name)))

to

library(quantmod);
library(purrr);

stocks <- c("AAPL", "MMM", "CAT", "MSFT", "TSLA");

map_dfr(stocks, \(x) getDividends(x, name = "%s") |> 
                     fortify.zoo(melt  = TRUE, names = c("date", "name", "div")) |>
                     tail(2) )

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions