Run Sweave or knitr with objects from existing R session

前端 未结 4 1696
伪装坚强ぢ
伪装坚强ぢ 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:39

    I think it just works. If your Sweave file is named "temp.Rnw", just run

    > x <- 5
    > Sweave("temp.Rnw")
    

    You'll have to worry about naming the resulting output properly so each report doesn't get overwritten.

提交回复
热议问题