0

I am using "edgarWebR" package to get the data from USSEC EDGAR website. There is a function in the package called "company_filings", which has several arguments and I would like to use four of the arguments and it should be like this -

company_filings (comp, type = c('10-K','10-Q'), before = 20181231, count = 40)

where comp is a vector defined as follows -

comp <- c ("AAPL", "GOOG", "INTC")

but the company_filings function accepts only one element at a time in comp vector - for example -

company_filings ("AAPL", type = c('10-K','10-Q'), before = 20181231, count = 40)

Actually, I use the following code to get the results for all elements in comp vector -

filing <- Reduce(rbind, lapply(comp, company_filings))

but it does not work. Can anybody help me in this respect?

I appreciate your help.

Sharif
  • 163
  • 1
  • 9

1 Answers1

0

To use functions in the apply family, the function in question should be of a single variable. You can create an anonymous function of one variable from a function of several variables and do something like:

sapply(comp,function(x){company_filings (x, type = c('10-K','10-Q'), before = 20181231, count = 40)})
John Coleman
  • 51,337
  • 7
  • 54
  • 119
  • @ John Coleman it creates list, but I need data frame. I use `filing <- lapply(comp,function(x){company_filings (x, type = c('10-K','10-Q'), before = 20181231, count = 40)})` and then `filing2 <- data.frame(t(sapply(filing, c)))` for data frame. but every variable has become vector – Sharif Jul 12 '19 at 16:54