I simply want to read a file and output it in the console. print( readLines(...) ) is the best I can do so far, but I don't want a line-by-line identifier, I just want the file as-is.
You could use system
to call a system command.
system("cat yourfile.txt")
Here's an elegant way using dplyr
library(dplyr)
readLines("init.R") %>% paste0(collapse="\n") %>% cat
or with base R
cat(paste0(readLines("init.R"), collapse="\n"))
remember to replace init.R
with the file path myfolder/myfile.R
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With