Import stock prices

stocks <- tq_get(c("HMC", "WMT", "TGT"),
                 get = "stock.prices",
                 from = "2016-01-01",
                 to = "2023-01-01")
stocks
## # A tibble: 5,286 × 8
##    symbol date        open  high   low close volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>  <dbl>    <dbl>
##  1 HMC    2016-01-04  30.9  31    30.7  31.0 760600     26.2
##  2 HMC    2016-01-05  30.8  30.9  30.7  30.8 517100     26.0
##  3 HMC    2016-01-06  30.4  30.4  30.1  30.2 433100     25.6
##  4 HMC    2016-01-07  29.8  29.9  29.4  29.5 650600     25.0
##  5 HMC    2016-01-08  29.9  30.0  28.8  28.9 862500     24.4
##  6 HMC    2016-01-11  29.2  29.4  29.0  29.4 943600     24.8
##  7 HMC    2016-01-12  30.1  30.1  29.5  29.9 897900     25.3
##  8 HMC    2016-01-13  30.3  30.3  29.6  29.7 680200     25.1
##  9 HMC    2016-01-14  29.7  30.1  29.4  30.0 705900     25.3
## 10 HMC    2016-01-15  29.1  29.3  28.8  29.0 572900     24.6
## # … with 5,276 more rows

Plot stock prices

stocks %>%
    
    ggplot(aes(x = date, y = adjusted, color = symbol)) +
    geom_line()