删除文件夹中每个RMarkdown的最后10行
我希望运行一个R脚本,在那里我可以删除每个Rmarkdown文件的最后10行,因为最后10行是机密内容。我总共得到了10次这样的降价。有没有比一个接一个更好的方法 我已经提供了一个虚拟的标记时间删除文件夹中每个RMarkdown的最后10行,r,r-markdown,R,R Markdown,我希望运行一个R脚本,在那里我可以删除每个Rmarkdown文件的最后10行,因为最后10行是机密内容。我总共得到了10次这样的降价。有没有比一个接一个更好的方法 我已经提供了一个虚拟的标记时间 --- title: "Untitled" author: "Unknown" date: "28/05/2021" output: pdf_document --- ## R Markdown This is an R Markdown
---
title: "Untitled"
author: "Unknown"
date: "28/05/2021"
output: pdf_document
---
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
## Including Plots
You can also embed plots, for example:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Including Plots
You can also embed plots, for example:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Including Plots
You can also embed plots, for example:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Including Plots
You can also embed plots, for example:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
---
标题:“无标题”
作者:“未知”
日期:“2021年5月28日”
输出:pdf\U文件
---
##降价
这是一份R降价文件。Markdown是一种用于编写HTML、PDF和MS Word文档的简单格式语法。有关使用R标记的更多详细信息,请参阅。
当您单击**Knit**按钮时,将生成一个文档,其中包括文档中任何嵌入的R代码块的内容和输出。您可以像这样嵌入R代码块:
##包括情节
还可以嵌入打印,例如:
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
##包括情节
还可以嵌入打印,例如:
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
##包括情节
还可以嵌入打印,例如:
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
##包括情节
还可以嵌入打印,例如:
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
您可以使用读线
和写线
进行以下操作:
txt <- readLines("test.md")
N <- length(txt)
writeLines(txt[1:(N-10)], "test_short.md")
txt您可以使用readLines
和writeLines
来执行以下操作:
txt <- readLines("test.md")
N <- length(txt)
writeLines(txt[1:(N-10)], "test_short.md")
txt或更短的writeLines(head(readLines)(“test.md”),-10),“test\u short.md”)
或更短的writeLines(head(readLines)(“test.md”),-10),“test\u short.md”)