使用库 rtf 将 R 表达式插入到单词中

Insert R expressions to word using library rtf

我想知道是否可以将 R 表达式或 R 对象插入到一个单词中:

示例:

  data(mtcars)

    (table=head(mtcars,20))
    addParagraph(doc, "\n\n Table cars \n")
    addTable(doc, cbind(rownames(table), table))
    nrow(mtcars)

    In this table we can see that data contain nrow(mtcars) rows

但是用我的话来说会显示:

    "In this table we can see that data contain 32 rows"

提前致谢 R

我终于可以将一个对象插入到一个单词中了。使用 rtf 和胶水包:

library(rtf)
library(glue)

data(mtcars)
total=nrow(mtcars)
addText(todo, glue("In this table we can see that data contain {nrow(mtcars)} rows"))

我的话显示:

"In this table we can see that data contain 32 rows"