Linear breaks with a knife

Possible duplicate:
Adding Line Breaks to Code Blocks in R Markdown

Is there any option in knitr for storing strings in R code? After compiling the document, the code should be displayed, as in the following example:

\documentclass[a4paper]{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \begin{document} <<hist>>= df <- data.frame(x=rnorm(100,100,20)) library(lattice) histogram(~x, df, main="histogram", nint=20) @ \end{document} 

Thank you for your help!

+8
r knitr latex
source share
1 answer

knitr automatically arranges the R code. To get line breaks, set tidy=FALSE , i.e.

 <<hist, tidy=FALSE>>= df <- data.frame(x=rnorm(100,100,20)) library(lattice) histogram(~x, df, main="histogram", nint=20) @ 
+11
source share

All Articles