我有以下請求如何捕獲RCurl詳細輸出
library(RCurl)
res=getURL("http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=RCurl&btnG=Search",
.opts=list(verbose = TRUE)
)
和想捕捉呼叫的詳細輸出(即,什麼被印刷在紅色R控制檯)。我認爲輸出行是消息,因此打印到stderr()
。以下作品的消息
sink(textConnection("test","w"),type="message")
message("test message")
sink(stderr(),type="message")
test
#[1] "test message"
但如果我被要求RCurl更換res=getURL(.....)
作爲message("test message")
上面給出。 顯然,RCurl的輸出不會打印到stderr()
。它也不打印到stdout()
。
那麼,如何捕獲輸出?
紅利問題:sink(stderr(),type="message")
是否將連接設置回R的默認值?
謝謝你的幫助!
發送輸出回控制檯:'sink()'輸出和'sink(type =「me ssage「)'stderr。在'?中看到例子? sink'。 – Thomas
好的!所以我可以省略'stderr()'。謝謝! – cryo111