Search code examples
rshiny

Create a multilines Readme.txt with R


I would like to create a txt file with multiple lines. Being a problem much asked, I found several solutions (like "\ n" etc ...) but none seems to work in my case and I do not understand why. Whatever I do, my text is only displayed on one line. Here is what I tried :

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)

Desired display :


 SEN2EXTRACT APPLICATION

Sen2extract is a shiny application allowing you to extract time series of spectral indexes on your study sites.

Obtained result :

____________________________ SEN2EXTRACT APPLICATION____________________________Sen2extract is a shiny application allowing you to extract time series of spectral indexes on your study sites.


Solution

  • You have removed the usual new line characters from writeLines when writing to the file by changing sep. Then it looks like you want to add new lines separately but you are not writing these to the file, just the console.