infuser: a template engine for R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.