Run Sweave or knitr with objects from existing R session

前端 未结 4 1697
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 04:59

Suppose I have an object x in my current session:

x <- 1

How can I use this object in an Sweave or knitr document, without

4条回答
  •  一向
    一向 (楼主)
    2020-12-01 05:37

    Both Sweave and knitr makes use of the global environment (see globalenv()) when evaluating R code chunks, so whatever in your global environment can be used for your document. (Strictly speaking, knitr uses the parent frame parent.frame() which is globalenv() in most cases)

提交回复
热议问题