knitr is an R package for dynamic report generation based on the concept of literate programming.

learn more… | top users | synonyms

0
votes
0answers
16 views

Longtable in a knitr (PDF) document: using xtable (or kable)

I am new to knitr and I have had some very basic latex knowledge in the past, so I googled already hoping to find a solution that was already posted somewhere. However, I was not able to solve my ...
2
votes
0answers
34 views

SOLVED - Knitr/pandoc bibliography problem

I would try to convert the way I write my scientific articles from Sweave/LaTeX to knitr/pandoc. I've been able to reproduce almost everithing with the exceptions of the references. I googled a lot ...
1
vote
1answer
18 views

knitr creating a wrong second “#” in a deep hyperlink

I would like to compile a .Rnw Document in RStudio with knitr that includes a "#" in the hyperlink (deeplink) of a float caption. See the minimum working example: (compiled with R Studio Version ...
1
vote
0answers
33 views

Display if the variable is NA / not-NA

I have a variable assigned as a output of a function, which returns numeric value or NA. The following code mimics it. <<>>= data <- sample(c(TRUE, FALSE), size = 1, replace = TRUE) @ ...
1
vote
1answer
46 views

Setting width of page

I would like to control the width of the document, i was able to set the margins more the the left (https://stuff.mit.edu/afs/sipb/project/www/latex/guide/node30.html) But that just moved the text to ...
0
votes
1answer
36 views

Print binary output in knitr

Just showing an example to represent my seemingly simple problem. i generate a variable with random TRUE/FALSE. <<>>= data <- sample(c(TRUE, FALSE), size = 1, replace = TRUE) @ ...
1
vote
1answer
32 views

Lyx / Knitr - R Code in chunck goes beyond set width

I use Lyx (2.1.4) with knitr (1.10.5). I have a lot of trouble having the code chunks respect the width that I tried setting through various ways: In the chunk options (width=50); ...
0
votes
1answer
30 views

knitr example doesn't produce graphics

I tried compiling the given MWE for testing knitr: %% LyX 2.1.3 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are doing. ...
1
vote
1answer
20 views

How does knitr inject TeX code into the document?

I'm very new to knitr. How do I write R code in knitr that composes LaTeX from scratch and injects it into the document at a particular point? I'm thinking of something similar to what PHP or JSP ...
2
votes
1answer
76 views

Formatting R chunks when using knitr

How can I apply the same formatting with R chunks that I apply to regular listings? The following example shows a nicely formatting listing and an (IMHO) awful looking R chunk. I already loaded ...
1
vote
0answers
24 views

vim + knitr + synctex + file watch + sumatrapdf (on windows)

I'm trying to get a task runner watching a directory for changes and then run the following: knit Rnw file pdflatex the resulting tex file (with bibtex) open pdf viewer and have both forward/reverse ...
1
vote
1answer
47 views

Knitr pdf not working on Mac OS X error “! Missing $ inserted.”

I have the following chunk in rmarkdown {r } library(psych) a <- (matrix(c(1:1000), ncol=4)) f <- fa(a) But when I try to print inline the following output: `r f$null.chisq` I get the ...
1
vote
0answers
10 views

Using \adjustwidth seems to break with a figure caption in knitr

I need to adjust my margins so I can place two pictures side by side. This works when there is no caption on the picture but when I add a caption the margins revert back to how they were. ...
10
votes
2answers
269 views

Appending an empty row after every 5 or 10 rows in LaTeX table

I wonder how to append an empty row after every 5 or 10 rows in LaTeX table. Here is my MWE in .Rnw format. Any help will be highly appreciated. Thanks! \documentclass{article} ...
0
votes
0answers
35 views

Redefining the knitr code chunk delimeter in LaTeX to compile .Rnw files as .tex files

I am trying to define some LaTeX commands/environments to handle the raw text in an Rnw file (R + LaTeX document compiled with R package knitr). The goal is to allow someone to rename a .Rnw file to a ...
0
votes
1answer
45 views

knitr Caption figure without number

I am looking for a way to caption my figures without numbering them (like \caption*{}). I am not sure how to do this in knitr. The following example shows my first attempt: <<label, ...
0
votes
0answers
21 views

How to determine defaults for a \documentclass in LaTeX

I had been using tufte-handout in LaTeX, but it seems very inflexible and not well documented. My main problem was trying to figure out how to get a table to output in the center of the page (How to ...
2
votes
1answer
36 views

Iterate latex/kintr code

I am new to knitr/Sweave. I need to prepare different versions of an exam with randomly generated questions. One version per student, each with the student's name on it. Below is a simple example with ...
2
votes
1answer
105 views

Two tables (not hard-coded) side-by-side in LaTeX that will page break

I wrote my original question here: (Two tables side-by-side in LaTeX that will page break). Then, I realized I needed to revise my question, by also including an additional problem that comes with it. ...
2
votes
1answer
57 views

How can I conditionally reference a figure?

So here's my knitr .Rnw file: \documentclass{article} \usepackage{hyperref} \hypersetup{} \begin{document} \let\ref\autoref <<plot,fig.cap='try'>>= if(rnorm(1) > 0) x = rbinom(1, 100, ...
1
vote
1answer
94 views

what does this error message suggest?

An error just prompted up when I process an .Rnw file using RSudio: Loading required package: knitr Warning message: package ‘knitr’ was built under R version 3.1.2 processing file: ...
1
vote
1answer
41 views

knitr: less/greater than sign displayed as (¡) and (¿)

I'm a beginner in using knitr to generate a report. I have a R script (see below for an example; BTW I'm using RStudio for all of this) that runs without error and the output is a data frame. My ...
2
votes
2answers
73 views

Conditionally print text with inline R data via knitr

I want to conditionally print a sentence that contains a \Sexpr{} in knitr. How can this be done? I know I can conditionally print text using \Sexpr{} but I run into issues when the text to be printed ...
0
votes
0answers
14 views

Fill arbitrary number of “template analysis page” based on data output by R

I'm using knitr to produce a report on anomalies detected in a machine. I've got an R script that searches for anomalies (there can be an arbitrary number of anomalies) and the script also produces a ...
2
votes
2answers
85 views

Install knitr on own shareLatex server

EDIT: According to a ShareLatex Github discussion, I should create a .latexmkrc file and add the following code (I tried already in the home directory but it didn't work) : my $root_file = ...
2
votes
1answer
52 views

knitr render html code

How to render html output to pdf in knitr? Here is my code \documentclass{article} \begin{document} <<echo=TRUE, results= 'asis'>>= library(xtable) n <- data.frame(x = 1:6, y = 15:20) ...
1
vote
0answers
36 views

How can I remove extra spaces in code passed through probsoln package?

This is an easy question to a potentially complicated situation. I'm using RStudio to write homework and exams using the probsoln package that embeds R code into the LaTeX directly. I am using knitr ...
4
votes
1answer
57 views

Input Tex file in knitr file

I am showing a simple example here just to frame the question. \documentclass{article} \begin{document} <<>>= library('ggplot2') dataset <- diamonds @ \begin{table}[htbp] ...
2
votes
1answer
105 views

How to use Umlauts (äüö) in axis label with knitr, LuaTex and tikz?

When compiling pdf documents with complex tikz figures using knitr, the pdftex engine would sometimes run out of memory. Thus, I used the luatex engine to compile these Rnw files. However, I am not ...
2
votes
2answers
48 views

shrink knitr output to multiple columns

I am providing a very simple example here. In my dataset, I have 50+ names in column. I get annoyed by the fact that colnames() output takes 50+ lines too! Is it possible to divide the output over ...
1
vote
1answer
95 views

chunk on a new page in knitr

I have a situation where i am knitting a bunch of figures in \enumerate and figures are big such that I would prefer one page for every figure. \documentclass{article} \begin{document} ...
0
votes
1answer
74 views

Modify R output in LaTeX

I'm currently writing a paper for my bachelor thesis with LaTeX. I'm pretty new to LaTeX and I was wondering whether I can modify the R output in LaTeX. For Example: If I type in this: ...
1
vote
1answer
239 views

Creating Bold Column Headers using xtable (knitr)

what is the easiest way to bold all column headers using the output of calling xtable, ideally under the print.xtable command. I am using knitr.
2
votes
2answers
78 views

bundledoc fails with subfolder paths (MiKTeX)

I would like to use bundledoc mainly in Windows with MiKTeX. However, I encounter a problem with subfolder paths that is annoying. I run the program as follows: bundledoc --config=miktex.cfg ...
1
vote
1answer
114 views

Capturing final figure caption using knitr

I'm writing a paper for the journal PLOSone. They require that figure captions be placed in the article but not the figure itself (it's submitted separately). So I'm wondering how to get knitr to ...
2
votes
0answers
122 views

R-code linebreaks AND themes in knitr

hpesoj626 provides two great minimal working examples for how to get R-code linebreaks AND code highlighting in knitr. I was wondering if it was possible to use Yihui's knitr themes within either of ...
1
vote
0answers
70 views

Table dull when transferred from R to word [closed]

I am using latex in R (mostly copied codes) to make beautiful tables. But transferring tables with the help of snipping tool used or saved as jpg from R to word, the table looks dull and not rich ...
0
votes
0answers
58 views

R data.table and knitr

I have an automated report that i produce using knitr. i'm running across the oddest problem. I wrote a function that sums the data by month for several locations. when i run this function in R i ...
0
votes
0answers
50 views

Unwanted white space with knitr+booktabs package

I want to include a table in my latex document that I create using knitr package. I "call" the table using: \begin{table}[H] \begin{centering} <<r second part}>>= kable(Per_cond, ...
2
votes
0answers
45 views

After updating to LyX 2.13: getting this message Sweave Noweb syntax? [closed]

After updating to LyX 2.1.3, I'm getting this message Sweave Noweb syntax?. I wonder what message mean and why I'm getting it? After clicking on ok, it works but I'm looking to not show this ...
1
vote
1answer
64 views

Why does this fail in LyX 2.1.3 but works in .Rnw?

This code works fine in .Rnw but does not work in LyX 2.1.3. In LyX 2.1.3 it throws the following error: Error in getModel.baseGmm(all_args, ...): could not find function "is" Any idea how to ...
1
vote
2answers
351 views

knitr in RStudio produces 'Undefined control sequence', alongside other issues

I am getting multiple issues being reported when I try to 'Compile PDF' for a knitr document in RStudio (Windows 7), although the .pdf is still produced in the working directory. I am using R 3.1.3, I ...
5
votes
0answers
115 views

What are the advantages of switching to Emacs for TeX/knitR work?

Currently, I am using TeXStudio. Now, I am considering to switch to Emacs because I heard that is has its advantages when it comes to R and knitR. But what are the specific advantages? Yet, I am still ...
0
votes
0answers
223 views

utf8 encoding problems with knitr

I'm using RStudio 0.98.1102 on Windows 7 with knitr 1.10 (R 3.1.2) and tried to knit the following file: \documentclass{article} \usepackage[ngerman]{babel} \usepackage[utf8]{inputenc} ...
0
votes
1answer
59 views

knitr-manual.lyx fails to compile on LyX 2.1.2

My error message gives me the following: An error occurred while running: Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX 2.1/Resources/scripts/lyxknitr.R" ...
0
votes
0answers
196 views

Best way to Insert R code into a LyX document

Let's suppose that I have a set of R (3.1.2) scripts that I would like to display in LyX (2.1.2). I could use Program Listings, but I think this looks very unprofessional. I am wondering if anyone can ...
2
votes
1answer
80 views

Insert knitr (1.9) Chunks From Separate File Into Lyx (2.12) Document

I have a LyX document (report class) called mwe.lyx and I would like to execute the following Rmd chunk called "mwe.Rmd". {r, eval = FALSE, echo = TRUE, cache = FALSE} 2+2 Of course, I can ...
2
votes
1answer
131 views

How to modify knitr output chunk

I know that it's possible to tweak the output of a knitr code chunk so that it looks the way you want. My problem occurs when using the parskip package. The parskip package adds an extra bit of space ...
1
vote
0answers
61 views

Blog publishing / creation from Latex

I have been using Latex for a few years, and have several articles written in Latex. I want to share some of these articles on blogs, and I am very new to the blogging world. Just wondering if there ...
1
vote
0answers
58 views

Using xtable with listings package

I am the listings package as suggested by the following solution provided in this question: Getting Sweave code chunks to stay inside page margins? More specifically, I am using the following piece ...