首页 > 解决方案 > r edgar 错误:输入年份不是数字

问题描述

我有一个包含 3 家公司(ciknum 变量)和每家公司提交年度报告的年份(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

获得 MasterIndex 文件夹并运行代码(请参阅建议的解决方案)后,我使用 R edgar 包获得 10-K 文件。我运行以下代码:

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")
}

它不断吐出以下错误:Error: Input year(s) is not numeric. 我检查了变量类型,似乎我的 fyearq 变量是数字的。

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

不太明白为什么 my_getFilings 函数不读取“数字” fyearq 变量。任何帮助将非常感激。

先感谢您。

标签: rfor-loopnumericedgar

解决方案


Martins 这里的排序似乎很重要。我通过使用函数中的描述符解决了这个问题,所以

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

正如你所写的那样

my_getFilings(cik.no = firm, form.def = '10-K', filing.year = 2016, downl.permit = "y")

推荐阅读