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
58
votes
1 answer

Animated rgl graphs with knitr

I want to include animated rgl graphs in my .Rnw document through knitr. Here is my MWE: \documentclass{article} << label = setup, include = FALSE>>= opts_chunk$set(fig.path = 'figure/', cache = FALSE, dev = "pdf", fig.align = 'center', fig.show…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
18
votes
1 answer

Printing p-values with <0.001

I wonder how to put <0.001 symbol if p-value is small than 0.001 to be used in Sweave. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
13
votes
3 answers

Putting line number for R code with knitr

I wonder if there is any function to put line numbers with knitr in .Rnw. I found this discussion and some documents (now removed from the web) but could not find the way to put line numbers.
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
12
votes
2 answers

How do I 'prebuild' a vignette index for an R package?

I'm preparing a package for submission to CRAN. I use R CMD build myPackage then R CMD check myPackage --as-cran and it passes all checks with no notes or warnings. However, each time I try to submit, I get the following error message from one of…
dardisco
  • 5,086
  • 2
  • 39
  • 54
12
votes
1 answer

r knitr chunk options for figure height / width are not working

I used to use knitr in R to produce reports from the .Rnw format. In my reports I often put a plenty of plots and manipulated their size with the use of chunk optios, e.g.: \begin{figure}[h!] \centering <
Marta Karas
  • 4,967
  • 10
  • 47
  • 77
10
votes
1 answer

xtable in .Rmd then knit as pdf in rstudio shows % comments

I am making a PDF using Rstudio's 'knit PDF' option when writing an R Markdown (.Rmd) file. When creating a table using the xtable function, text commented in latex using the % is displayed in the pdf. This problem goes away when knitting a .Rnw…
7
votes
3 answers

Detecting whether shiny runs the R code

I would like to run R code in two locations, in an Rnw file and as an interactive shiny R markdown document. Thus, what I need, since interactive shiny components do not work in Rnw files, is a code snippet in R that detects whether to load the…
Xiphias
  • 4,468
  • 4
  • 28
  • 51
7
votes
1 answer

knitr single space code when class defaults double space (Rnw)

When using knitr with a class like apa6e the code chunks default to double space like rest of the document. This is not desirable. This could be altered by wrapping with: \begin{singlespace} <<*>>= CODE @ \end{singlespace} How can this be done…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
6
votes
0 answers

Code chunk highlighting when chunk has a pagebreak in pdf (knitr)

Here is an .Rnw file containing a random code chunk that is, when knitted to pdf, printed on two pages. I noticed that code chunk highlighting stops after a pagebreak. Why is that? How do I fix it? The .Rnw file \documentclass{article} %%% Knitr…
Manuel R
  • 3,976
  • 4
  • 28
  • 41
6
votes
2 answers

Working with Rstudio for writing thesis chapters in .Rnw

I got 2 files from my university for writing thesis using LaTeX. One is a .sty file and other one is .TeX file. In order to work in R studio I've decided to have separate .Rnw files for each chapter and one file for combining all the chapters. I…
umair durrani
  • 5,597
  • 8
  • 45
  • 85
5
votes
1 answer

SQL code in Rnw document with knitr

I used the following sql code in .Rmd document. However, I want to use the same SQL code in .Rnw document. ```{r label = setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, max.print = NA) ``` ```{r, echo=FALSE,…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
4
votes
1 answer

knitr kable: Text color in PDF from RNW is grey

When I create a table using the knitr::kable function within a RNW file, the text color of the table items in the PDF appears to be grey. I would like to change this to black. How can I do this?
der_grund
  • 1,898
  • 20
  • 36
4
votes
0 answers

keep code with figure in knitr

Is there a way to keep the code and the figure together in knitr when using a figure environment in LaTeX? This style: \documentclass{article} \begin{document} writing <>= with(mtcars, plot(mpg,…
beanumber
  • 767
  • 5
  • 13
4
votes
2 answers

How to apply a different numeric format to each row in R

I have a table which I want to display that has a mix of percents, integers, and floating point values each in different rows of the table. I would like to create formatted output in a R markup or Rnw file that nicely displays my table. I can do it…
Techniquab
  • 843
  • 7
  • 22
4
votes
1 answer

knitr shows comments from library import

I have a small Rnw file. When compiled with knitr, it shows importing comments in the pdf. How do I remove these comments? Here is the file…
highBandWidth
  • 16,751
  • 20
  • 84
  • 131
1
2 3 4 5 6