knitr::opts_chunk$set( echo = as.logical(params$show_code), message = FALSE, warning = FALSE )
library(tidyquant) library(dplyr) library(knitr) library(ggplot2)
This report contains market data for r params$symbols
. To make for something to plot, I suggest you pull 7 days worth of data.
# Get data stock_data_tbl <- tq_get( x = params$symbols, from = today()-7, to = today() ) %>% select(symbol, date, adjusted) kable(stock_data_tbl,caption="Last 7 days of market close")
# Create plot with gain/loss ## you to do ggplot(data = stock_data_tbl, aes(x = date, y = adjusted, col = symbol)) + geom_line() + ylab("stock price")
# save data # do you want to have a single running RDS file, or a file for every time this runs # up to you to decide saveRDS(stock_data_tbl, "../data/stock.RDS")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.