Import stock prices

stocks <- tq_get(c("HMC", "TM"),
                 get = "stock.prices",
                 from = "2016-01-01",
                 to = "2024-01-01")
stocks
## # A tibble: 4,024 × 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     25.1
##  2 HMC    2016-01-05  30.8  30.9  30.7  30.8 517100     24.9
##  3 HMC    2016-01-06  30.4  30.4  30.1  30.2 433100     24.5
##  4 HMC    2016-01-07  29.8  29.9  29.4  29.5 650600     23.9
##  5 HMC    2016-01-08  29.9  30.0  28.8  28.9 862500     23.4
##  6 HMC    2016-01-11  29.1  29.4  29.0  29.4 943600     23.8
##  7 HMC    2016-01-12  30.1  30.1  29.5  29.9 897900     24.2
##  8 HMC    2016-01-13  30.3  30.3  29.6  29.7 680200     24.1
##  9 HMC    2016-01-14  29.7  30.1  29.4  30.0 705900     24.3
## 10 HMC    2016-01-15  29.1  29.3  28.8  29.0 572900     23.5
## # ℹ 4,014 more rows

Plot stock prices

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