0

I have a "test" dataframe with 3 companies (ciknum variable) and years in which each company filed annual reports (fyearq):

    ciknum  fyearq
1   1408356 2012
2   1557255 2012
3   1557255 2013
4   1557255 2014
5   1557255 2015
6   1557255 2016
7   1555538 2013
8   1555538 2014
9   1555538 2015
10  1555538 2016

After obtaining the MasterIndex folder and running this code (see proposed solution) I use the R edgar package to obtain 10-K filings. I run the following code:

for (i in 1:nrow(test)){
  firm<-test[i,"ciknum"] #edit: seems like mistake can be here since new firm data only contains 1 obs of 1 variable
  year<-test[i,"fyearq"] #edit: seems like mistake can be here since new year data only contains 1 obs of 1 variable
  my_getFilings(firm,'10-K',year,downl.permit="y")
}

And it keeps spitting the following error: Error: Input year(s) is not numeric. I checked the variable type and it seems my fyearq variable is numeric.

sapply(test,class)
   ciknum    fyearq 
"numeric" "numeric"

Don't really understand why the "numeric" fyearq variable is not read as such by the my_getFilings function. Any help would be much appreciated.

Thank you in advance.

martins
  • 441
  • 1
  • 5
  • 19

2 Answers2

0

Martins The ordering seems to matter here. I solved this problem by using the descriptor from the function, so that

my_getFilings(firm,'10-K',year,downl.permit="y")

as you wrote is written as

my_getFilings(cik.no = firm, form.def = '10-K', filing.year = 2016, downl.permit = "y")
Bartosz Konieczny
  • 1,985
  • 12
  • 27
M Grace
  • 1
  • 2
0

Thank you @bartosz25 and M Grace,

I finally made it work through the following code:

for (row in 1:nrow(test)){
  firm <- as.numeric(test[row, "ciknum"])           
  year <- as.numeric(test[row, "fyearq"])
  my_getFilings(firm, c('10-K'), year, downl.permit="y")
}

Apologies for not posting it before.

martins
  • 441
  • 1
  • 5
  • 19