Questions tagged [rnw]

.Rnw is a file extension used for documents with markup and and/r chunks.

determines the appropriate set of patterns (regular expressions) to use to extract code and chunk options based on the file extension (if the patterns are not provided in advance). See ?knit_patterns for more information.

84 questions
0
votes
1 answer

How to use different "dev.off()" with knitr (to auto-crop figures)

I would like to use my own pdf() plot device in an .Rnw document converted to a PDF with knitr. After the PDF of a figure is generated it should call pdfCrop.off() instead of dev.off() (or whatever knitr calls); this would perfectly crop the…
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102
0
votes
1 answer

kableExtra:: LaTeX commands are not rendering properly in add_header_above

I want to use LaTeX commands in add_header_above function of kableExtra library(kableExtra) x1 <- knitr::kable(head(mtcars), "html") add_header_above(x1, c(" ", "Group 1" = 5, "Group 2" = 6)) add_header_above(x1, c(" ", "\\alpha" = 5, "Group 2" =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
1 answer

Reference one of several figures in r code chunk of a Rnw file

Creating a parameterized report with an rnw file. I am trying to reference specific figures from a code chunk that has multiple figures in it (generated by a loop through a list of figures). I know if there's a single figure I can reference it from…
Sahir Moosvi
  • 549
  • 2
  • 21
0
votes
1 answer

knitr file ended while scanning use of \@xverbatim

I have the following .Rnw file: \documentclass{article} \usepackage[table]{xcolor} \usepackage{multicol} \begin{document} \begin{multicols}{2} \hskip-3.5cm\begin{tabular}{|l|} \hline \cellcolor[RGB]{0,0,140}{\large\textbf{\textcolor{white}{Bill…
ytk
  • 2,787
  • 4
  • 27
  • 42
0
votes
1 answer

knitr sanitize_fn warning incorporating plots into latex via knit2pdf

I am dynamically generating pdf reports in R using a driver script that calls knit2pdf. My report source is latex, in a .Rnw file, and the call is like this: knit2pdf("source.Rnw",output=paste0(fname,".tex"),quiet=T) fname does not contain any…
0
votes
1 answer

Automating adding .tex file content to .Rnw files

I use a program to produce a series of .tex files. I then manually copy the contents of the .tex files and add it to a .Rnw file (Sweave, compiled in RStudio IDE). Is there a way to automatically include the contents of .tex files in the .Rnw file…
socialscientist
  • 3,759
  • 5
  • 23
  • 58
0
votes
1 answer

How to convert a .Rnw to an R script

I want to extract from an RNW all the chunks with R programming and put them in a separate file I have a long rnw file and would find it tedious to do that manually. Is there a function or a script to do that ?
0
votes
0 answers

Distinct colors for R input and output in Rnw chunks - knitr

I'd like to render R input and output code from the same Rnw chunk using two different colors so that they can be more easily interpreted. So far my attempts failed while using a custom CSS template, where any change in colors appear to…
0
votes
0 answers

Modifying space around a Knitr code chunk

Is it possible to modify the space around a specific KnitR code chunk within a .rnw file that is going to be weaved into a PDF. There is a question and answer about changing the options globally... add space between document text and knitr code…
Frost_Maggot
  • 309
  • 2
  • 12
0
votes
0 answers

Can't get images to work with .Rnw files on RStudio

I've been trying to debug a .Rnw file I wrote in RStudio for about a week now. The most frustrating part is that it used to work perfectly in its current form but then seemed to inexplicably stop working. I've tracked down the source of the error…
Neal
  • 199
  • 3
  • 16
0
votes
1 answer

knitr minimal example do no show figures

I have problems running the minimal knitr rnw example in Rstudio. I got the following minimal example from his github %% LyX 2.2.1 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are…
statquant
  • 13,672
  • 21
  • 91
  • 162
0
votes
1 answer

Knitr: Use nested loops to generate multiple reports

A previous post on StackOverflow had a very useful guide on how to use a template .Rnw file to produce multiple reports. I'd like to duplicate this, except I'd have 4 loops rather than just the one used in the example. In my case, these are the…
0
votes
1 answer

Source or input or include Rmd file in a Rnw document

I am trying to write my paper and using Elsevier document class as a Rnw document. I also tried to use rticle package which I find little difficult to customise. Is it possible to include Rmd file in my Rnw document so that I can use the Rnw frame…
TheRimalaya
  • 4,232
  • 2
  • 31
  • 37
0
votes
1 answer

Beamer with Devnagari / Hindi

I have a project with Hindi text which I am successfully able to knit when the document class is article or report or book. However, as soon as I make the class to be beamer, it starts giving me error. Any ideas if beamer works with Devnagari?
Shambho
  • 3,250
  • 1
  • 24
  • 37
0
votes
1 answer

naming of sections in Rnw script in rstudio

In standard R scripts, sections can be labelled by adding four dashes after a comment. E.g. # simple math ---- 1+1 looks like this: how can I label sections in a Rnw script? Four dashes don't work here. See:
jmjr
  • 2,090
  • 2
  • 21
  • 31