每次getFilings提示'Yes'
Prompt 'Yes' every time to getFilings
我打算使用 EDGAR 包为 R 中的几家公司下载 2005 10-Ks。我有一个迷你循环来测试哪个有效:
for (CIK in c(789019, 777676, 849399)){
getFilings(2005,CIK,'10-K')
}
但是每次 运行 时我都会收到 yes/no 提示,我必须输入 'yes':
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
如何提示 R 为每个 运行 回答 'yes'?谢谢
请记住在您的问题中包含一个最小的可重现示例,包括 library(...)
和所有其他必要的命令:
library(edgar)
report <- getMasterIndex(2005)
我们可以通过一些代码手术来绕过提示。在这里,我们检索 getFilings
的代码,并将要求提示的行替换为一条消息。然后我们将新函数 (my_getFilings
) 写入临时文件,source
该文件:
x <- capture.output(dput(edgar::getFilings))
x <- gsub("choice <- .*", "cat(paste(msg3, '\n')); choice <- 'yes'", x)
x <- gsub("^function", "my_getFilings <- function", x)
writeLines(x, con = tmp <- tempfile())
source(tmp)
一切正常下载:
for (CIK in c(789019, 777676, 849399)){
my_getFilings(2005, CIK, '10-K')
}
list.files(file.path(getwd(), "Edgar filings"))
# [1] "777676_10-K_2005" "789019_10-K_2005" "849399_10-K_2005"
我打算使用 EDGAR 包为 R 中的几家公司下载 2005 10-Ks。我有一个迷你循环来测试哪个有效:
for (CIK in c(789019, 777676, 849399)){
getFilings(2005,CIK,'10-K')
}
但是每次 运行 时我都会收到 yes/no 提示,我必须输入 'yes':
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
Total number of filings to be downloaded=1. Do you want to download (yes/no)? yes
如何提示 R 为每个 运行 回答 'yes'?谢谢
请记住在您的问题中包含一个最小的可重现示例,包括 library(...)
和所有其他必要的命令:
library(edgar)
report <- getMasterIndex(2005)
我们可以通过一些代码手术来绕过提示。在这里,我们检索 getFilings
的代码,并将要求提示的行替换为一条消息。然后我们将新函数 (my_getFilings
) 写入临时文件,source
该文件:
x <- capture.output(dput(edgar::getFilings))
x <- gsub("choice <- .*", "cat(paste(msg3, '\n')); choice <- 'yes'", x)
x <- gsub("^function", "my_getFilings <- function", x)
writeLines(x, con = tmp <- tempfile())
source(tmp)
一切正常下载:
for (CIK in c(789019, 777676, 849399)){
my_getFilings(2005, CIK, '10-K')
}
list.files(file.path(getwd(), "Edgar filings"))
# [1] "777676_10-K_2005" "789019_10-K_2005" "849399_10-K_2005"