Utility function for splitting a data.frame into rows. In a whisker template it can be useful to iterate over the rows of a data.frame or matrix. For example rendering a table in HTML.
rowSplit(x, ...)
data.frame
or matrix
other options will be passed onto split
dat <- head(InsectSprays)
dat <- unname(rowSplit(dat))
template <-
"{{#dat}}
count: {{count}}, spray: {{spray}}\n
{{/dat}}"
whisker.render(template)
#> [1] "count: 10, spray: A\n\ncount: 7, spray: A\n\ncount: 20, spray: A\n\ncount: 14, spray: A\n\ncount: 14, spray: A\n\ncount: 12, spray: A\n\n"