UPDATED Question 1 In the lattest update of KnitR the output is clean as what I expected. Maybe an update was made.
Before update
I'm trying to get a particular output with Sweave and R code. For now I have this code :
\documentclass[11pt,french]{report}
\usepackage{babel} %%french
\usepackage{amsmath,amsfonts,amssymb} %%maths
\usepackage[utf8]{inputenc} % LaTeX
\usepackage[T1]{fontenc} % LaTeX
\usepackage[dvipsnames,table,xcdraw]{xcolor}
%% Background code chunk
\usepackage{listings}
\usepackage{color}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
%% background code chunk listing
\lstset{
language=R}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
witch is coming from this site.
The R code I'm trying to implement is :
%% script R
\begin{lstlisting}[linerange=\\begin\{Sinput\}-\\end\{Sinput\},includerangemarker=false, caption = Code source en R pour l'exemple]
<<eval =FALSE>>=
# dataset
x <- c(2,3,6,9,12); y <- c(2,5,3,6,5)
# Estimations des parametres
reg <- lm(y ~ x)
# Resume de l'estimation
summary(reg)
# Valeurs de Yt
fitted(reg)
# Residus
residuals(reg)
@
\end{lstlisting}
My questions :
1- How can I get a better output for the ~ symbol ?
2- Is there a way to eval the code without getting and output like this ?
eval =FALSE
and depending of what you want exactly , addecho=FALSE
orresults='hide'
. – Fran Aug 6 '18 at 21:09