knitr gets tricked by data.table `:=` assignment

前端 未结 5 954
不知归路
不知归路 2020-11-29 23:44

It seems that knitr doesn\'t understand that DT[, a:=1] should not result in an output of DT to the document. Is there a way to stop

5条回答
  •  清歌不尽
    2020-11-30 00:26

    I've run across the same problem and I solved it fairly easy by re-assigning the variable. In your case:

    DT <- DT[, ':=' (c, 5)]
    

    It's a bit more verbose though, especially if the variable name is big.

提交回复
热议问题