使用 R 创建多行 Readme.txt
Create a multilines Readme.txt with R
我想创建一个包含多行的 txt 文件。作为一个经常被问到的问题,我找到了几个解决方案(如“\ n”等......)但 none 似乎适用于我的情况,我不明白为什么。无论我做什么,我的文字都只显示在一行上。这是我尝试过的:
Readme <- file("Readme.txt", "w")
writeLines("____________________________", Readme, sep = "")
writeLines("\n")
writeLines(" SEN2EXTRACT APPLICATION", Readme, sep = "")
writeLines("\n")
writeLines("____________________________", Readme, sep = "")
writeLines("\n")
writeLines("Sen2extract is a shiny application allowing you to extract
time series of spectral indexes on your study sites.", Readme, sep = "")
close(Readme)
需要显示:
SEN2EXTRACT APPLICATION
Sen2extract is a shiny application allowing you to extract time series
of spectral indexes on your study sites.
得到的结果:
____________________________ SEN2EXTRACT APPLICATION____________________________Sen2extract is a shiny
application allowing you to extract
time series of spectral indexes on your study sites.
通过更改 sep
写入文件时,您已从 writeLines
中删除了常用的换行符。然后看起来你想单独添加新行但你没有将它们写入文件,只是控制台。
我想创建一个包含多行的 txt 文件。作为一个经常被问到的问题,我找到了几个解决方案(如“\ n”等......)但 none 似乎适用于我的情况,我不明白为什么。无论我做什么,我的文字都只显示在一行上。这是我尝试过的:
Readme <- file("Readme.txt", "w")
writeLines("____________________________", Readme, sep = "")
writeLines("\n")
writeLines(" SEN2EXTRACT APPLICATION", Readme, sep = "")
writeLines("\n")
writeLines("____________________________", Readme, sep = "")
writeLines("\n")
writeLines("Sen2extract is a shiny application allowing you to extract
time series of spectral indexes on your study sites.", Readme, sep = "")
close(Readme)
需要显示:
SEN2EXTRACT APPLICATION
Sen2extract is a shiny application allowing you to extract time series of spectral indexes on your study sites.
得到的结果:
____________________________ SEN2EXTRACT APPLICATION____________________________Sen2extract is a shiny application allowing you to extract time series of spectral indexes on your study sites.
通过更改 sep
写入文件时,您已从 writeLines
中删除了常用的换行符。然后看起来你想单独添加新行但你没有将它们写入文件,只是控制台。