Help with pulling out data and running code on it simultaneously

Hi all! I am relatively new to R. I have imported an xlsx file from excel which contains Stock halt data... The data I am interested in is contained in 2 separate columns which are the Date of each event and the Stock ticker for each event. Using the tq_get function to retrieve stock timeseries data, I'm wondering how I could make this process more automated. Since I have the stock ticker data in one column of that excel file and the Date in the other column I'm curious how I could tell R to run through the excel file and input the stock ticker for that part of the function and then using the data correlated with that symbol and for example (subtract a week for the "from" portion and add a week for the "to" portion) and have that be input as well. My goal is to not have to write out this function one by one because each stock symbol I want to pull information about has a different time range that I would like information on associated with it. Please let me know if I need to go into more detail about what I would like done or if it simply not doable.
Thanks!

# get historical data for multiple stocks. e.g. GAFA (tidyquant)
tq_get(c("GOOGL","AMZN","FB","AAPL"), get="stock.prices")

#quantmod
library(quantmod)
getSymbols("NNVC", from = "2021-2-10", to = "2021-3-10", auto.assign = TRUE)

You can use the purrr package to iterate over your excel data with functional programming.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.