質問

セッション全体をキャプチャするリダイレクト以外に、Rセッション中にログ記録を開始して停止する方法はありますか?明確にするには、Stataのlog usingコマンドに似たものを探しています。

役に立ちましたか?

解決

Do you know about sink() in base R ?

There are also some logging packages on CRAN: logging, log4r and possibly more.

Lastly, Emacs user have ESS and its transcript mode. You can save your session as a log, and in general, the 'work from file and execute from the file' approach builds a (partial, commands-only) log as you work.

他のヒント

For the sake of completing the answer using sink

# copy the log to a text file
sink("./logofcode.txt")
Your R code(s) goes here
you can use a stored R code as well using source()
source("./XS_SPEC_CF.R",echo=T, max.deparse.length=1e3)
sink()

There's savehistory(file) which will write the entire history as plaintext, or, if you're trying to log output, use sink(file, split = TRUE).

In addition to the sink function you might also look at the txtStart and related functions in the TeachingDemos package or the similar functionality in the R2HTML package (which came first).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top