1

Using the tidyquant package in R I downloaded stock data from 2 firms. I want to add a column with the lowest (adjusted) stock prices for each firm. The code below only adds the lowest for both firms together. What am I doing wrong? Is this the correct (dplyr)-way, or not?

data <- c("AAPL", "MMM") %>% tq_get(get  = "stock.prices",
                                    from = 1980-01-01,
                                    to   = 2018-05-05)

data %>% group_by(symbol) %>% mutate(lowest=min(adjusted, na.rm=TRUE))
cmaher
  • 5,100
  • 1
  • 22
  • 34
  • 1
    Your dplyr code works for me, but to get the data I needed to include the `from` and `to` dates as strings (e.g. `"1980-01-01"` and not `1980-01-01`); otherwise, `tq_get` wasn't pulling complete data. – cmaher May 06 '18 at 19:40
  • weird, now it works for me as well. Apparently some other package was in the way:( – Tall Measure May 06 '18 at 21:45

0 Answers0