Is R turning into an operating system?

Over the years I convinced my colleagues and IT guys that LaTeX/XeLaTeX is the way forward to produce lots of customer reports with individual data, charts, analysis and text. Success! But of course the operating system in the office is still MS Windows.

With my background in Solaris/Linux/Mac OSX I am still a little bit lost in the Windows world, when I have to do such simple tasks as finding and replacing a string in lots of files. Apparently the acronym is FART (find and replace text).

So, what to you do without your beloved command line tools and admin rights? Eventually you start using R instead. So here is my little work-around for replacing “Merry Christmas” with “Happy New Year” in lots of files:

 for( f in filenames ){

  x <- readLines(f)
  y <- gsub( "Merry Christmas", "Happy New Year", x )
  cat(y, file=f, sep="\n")

}
You can find a complete self-contained example on github.

Of course R is not an operating system, but yet it can complement it well, if your other resources are limited.

Last but not least: Happy New Year!

Citation

For attribution, please cite this work as:

Markus Gesmann (Dec 31, 2011) Is R turning into an operating system?. Retrieved from https://magesblog.com/post/2011-12-31-is-r-turning-into-operating-system/

BibTeX citation:

@misc{ 2011-is-r-turning-into-an-operating-system,
 author = { Markus Gesmann },
 title = { Is R turning into an operating system? },
 url = { https://magesblog.com/post/2011-12-31-is-r-turning-into-operating-system/ },
 year = { 2011 }
 updated = { Dec 31, 2011 }
}

Related