Skip to content

Instantly share code, notes, and snippets.

@swihart
Created February 5, 2015 16:50
Show Gist options
  • Save swihart/128560f46c0e0e7229c4 to your computer and use it in GitHub Desktop.
Save swihart/128560f46c0e0e7229c4 to your computer and use it in GitHub Desktop.
three examples from Karl Broman's Reproducible Research class
## from http://kbroman.org/Tools4RR/assets/lectures/03_knitr_Rmd.pdf
Tables
```{r kable}
x <- rnorm(100)
y <- 2*x + rnorm(100)
out <- lm(y ~ x)
coef_tab <- summary(out)$coef
library(kable)
kable(coef_tab , digits=2)
```
```{r pander}
library(pander)
panderOptions("digits", 2)
pander(out, caption="Regression coefficients")
```
```{r xtable, results="asis"}
library(xtable)
tab <- xtable(coef_tab , digits=c(0, 2, 2, 1, 3))
print(tab, type="html")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment