如何创建 R markdown 文件并将字符串变量附加到 R Markdown 文档

How to create a R markdown file and append a string variable to the R Markdown document

我是运行一个闪亮的应用程序,我想从中创建一个 R markdown 文件并将一串字符附加到 R Markdown 文档

rmd_content <- paste0("```Your R markdown string content",string_variable,"```")

rcon <- file("markdown_file.Rmd", "w") # Create Rmarkdown file
cat(rmd_content, file = rcon) # Write your content to Rmarkdown file
close(rcon)

在此 R 代码之后,您当前的工作目录中应该有一个名为“markdown_file.Rmd”的文件