The code comes out of the chunk in knitr texstudio

79 Views Asked by At

I use knitr in texstudio to include my R script into my document, but the problem is my code comes out of the color chunk background like this exemple

This is my code example

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\begin{document}
<<>>=

library(equatiomatic)
summary(cars)
extract_eq(lm(dist~speed,cars))
@

<<>>=
x <- rnorm(100)
y <- rnorm(100)
@

Throughout history, many people have wondered about the means of $x$ and $y$.
Today we can provide some answers. The mean of $x$ is approximately
\Sexpr{extract_eq(lm(dist~speed,cars))}. The mean of $y$ is approximately \Sexpr{round(mean(y), 3)}.
References

\end{document
0

There are 0 best solutions below