plot_growth: Plot Investment Growth

Description Usage Arguments Value Examples

View source: R/plot_growth.R

Description

Useful for comparing the performance of several investments, over their full histories or mutual lifetimes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plot_growth(
  prices = NULL,
  tickers = NULL,
  ...,
  gains = NULL,
  initial = 10000,
  plotly = FALSE,
  title = "Growth Over Time",
  base_size = 16,
  tooltip_size = 20,
  point_size = 1,
  line_size = 1,
  ticklabel_size = 8,
  legend_position = "right",
  return = "plot"
)

Arguments

prices

Data frame with one column of prices for each investment and a date variable named Date.

tickers

Character vector of ticker symbols that Yahoo! Finance recognizes, if you want to download data on the fly.

...

Arguments to pass along with tickers to load_gains.

gains

Data frame with one column of gains for each investment and a date variable named Date.

initial

Numeric value specifying value to scale initial prices to.

plotly

Logical value for whether to convert the ggplot to a plotly object internally.

title

Character string.

base_size

Numeric value to pass to theme_gray.

tooltip_size

Numeric value to pass to style.

point_size

Numeric value to pass to geom_point.

line_size

Numeric value to pass to geom_line.

ticklabel_size

Numeric value to pass to theme.

legend_position

Character string to pass to theme.

return

Character string specifying what to return. Choices are "plot", "data", and "both".

Value

Depending on return and plotly, a ggplot/plotly object, a data frame with the source data, or a list containing both.

A ggplot object.

Examples

1
2
3
4
5
## Not run: 
# Plot growth of $10k in VFINX and BRK-B
plot_growth(tickers = c("VFINX", "BRK-B"))

## End(Not run)

vandomed/stocks documentation built on July 22, 2020, 3:25 a.m.