TeX - LaTeX Asked by David Beauchemin on January 6, 2021
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=tinycolor{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 ?
The solution for question 2.
<<eval = TRUE, echo=FALSE, fig=TRUE, height=4,width=4.5>>=
[...] precedent code
@
The solution is just to add echo=false
and eval=false
for preventing the begin{Schunk}
and other Tex command.
Correct answer by David Beauchemin on January 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP