Reputation: 135
I have a dataframe data
of n
observations of several numeric and factor variables. I would like to produce a html report in which class
and describe
are reported and a histogram (qplot
or ggplot
) is plotted for every variable.
Thank you for your help.
Corrado
Upvotes: 0
Views: 974
Reputation: 49063
You can put a loop in your R chunks in Markdown files. Something like that for example :
```{r, echo=FALSE}
library(ggplot2)
```
This is an introductory sentence with absolutely no interest.
```{r, results="asis", eval=TRUE, echo=FALSE}
data(cars)
for (varname in names(cars)) {
var <- cars[,varname]
cat(paste0("<h2>",varname,"</h2>"))
cat(paste0("Class : <pre>",class(var),"</pre>"))
cat("Summary : <pre>")
print(summary(var))
cat("</pre>")
if (is.numeric(var)) print(qplot(var, binwidth=diff(range(var))/30))
}
```
This is an astonishing conclusion.
Which gives the following result : http://rpubs.com/juba/mdloop
Upvotes: 5