infuser: a template engine for R

May 17, 2015
By

(This article was first published on FishyOperations, and kindly contributed to R-bloggers)

Version 0.1 of infuser was just released on CRAN.

infuser is a very basic templating engine. It allows you to replace parameters in character strings or text files with a given specified value.

I would often include some SQL code in my R scripts so that I could make parameters in the SQL code variable. But I was always a bit hesitant on the cleanliness of this. It irked me so much that I finally wrote this very simple package. The infuse function allows me to read in a text file (or a character string for that matter) and infuse it with the requested values.

This means that I can now put my SQL code in a separate .sql file :). Load in into a character string with all the desired values in place and use it to my liking. Of course, the same thing can be done for any text file (e.g. an .html).

Information on usage and examples can be found here: http://github.com/Bart6114/infuser

To leave a comment for the author, please follow the link and comment on their blog: FishyOperations.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)