Not necessary for this pull request, but you should consider using a templating package like whisker or brew instead of handrolling this.
http://cran.r-project.org/web/packages/whisker/index.html