\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{url}
\begin{document}
<<setup, include=FALSE, cache=FALSE, echo = FALSE>>=
library(knitr)
library(pander)
opts_chunk$set(cache=TRUE, autodep=TRUE)
options(formatR.arrow=TRUE, width=90)
@
\title{Knitr dans CoCalc}
\author{Juanito Alima\~na}
\maketitle
Comme SageTeX, mais avec R. Le principe est essentiellement le même.
\medskip
\begin{center}
<<summary, echo = FALSE>>=
library(knitr)
x <- c(2,3,4,5,1,2,3,2,1)
kable(as.matrix(summary(x)))
@
\end{center}
\begin{figure}[h!]
\centering
<<histogram-plot, echo = F,fig.width=4, fig.height=4, out.width='.4\\linewidth'>>=
hist(x)
@
\caption{Voici l'histogramme}
\end{figure}
Sum of \Sexpr{paste(x, collapse=" + ")} is \Sexpr{sum(x)}.
\medskip
Voyons une tableau
<<kable, echo = FALSE>>=
n <- 100
x <- rnorm(n)
y <- 2*x + rnorm(n)
out <- lm(y ~ x)
library(knitr)
kable(summary(out)$coef, digits=2)
@
\end{document}