Questions tagged [knitr]
knitr is an R package for dynamic report generation based on the concept of literate programming.
370
questions
2
votes
2
answers
560
views
Why are the axis labels too large when using tikzDevice and lattice?
I'm working on a paper that is to be submitted to an Elsevier journal. The official guidelines state that:
As a general rule, the lettering on the artwork should have a
finished, printed size of ...
3
votes
3
answers
549
views
How to extract a series of text not in an environment, but with defined commands enclosing them
Under Windows 8, I am using R and the knitr package in RStudio with an .Rnw script. My regex skills are passable, but only in R.
My document has about thirty pages with a different text section at ...
1
vote
0
answers
443
views
XeLaTeX + knitr + Arial = error
When I compile the following:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
Hello.
<<foo, dev='tikz'>>=
library(ggplot2)
qplot(1)
@
\end{document}
...
1
vote
0
answers
856
views
How to solve the error: No counter 'sectionpage' defined [closed]
I'm trying to use this answer from a previous question to get frame numbers in a table of content in a beamer presentation made in RStudio with R Markdown and knitr (see file below; in in_header.tex ...
0
votes
1
answer
138
views
xtable: extend table to both columns
Using the xtable package, is it possible to give some option to xtable function to generate a tex file which will contain following:
```
\begin{table*}
...
\end{table*}
```
1
vote
2
answers
770
views
Where set font in tikzDevice-plots (.Rnw)
I'm trying to use sans serif fonts for the text in plots (ggplot2) made by R, within KOMA-book. Unfortunately I'm not very experienced in managing fonts and their families.
To keep things consistent, ...
2
votes
1
answer
2k
views
Using Calibri with a Mac
I am preparing a document, writing it in RStudio and knitr in a Mac (OS X El Capitan 10.11.2). I would like to use Calibri (to mimic Office documents). I already have a legal version of Microsoft ...
2
votes
1
answer
1k
views
Insert line break into knitr fig.cap?
I am using knitr and want to insert a line break in my fig.cap chunk option. Is this possible? The following is all I can think of but it doesn't work. I expect there's some evaluation option but I ...
2
votes
0
answers
167
views
What is the counterpart in LaTeX for the R package ezknitr and its tools for managing paths and directories
Dean Attali has just added an R package called ezknitr to CRAN. It enables those who use knitr and RMarkdown in .Rmd files to handle directories quite flexibly. His blog describes it well: path ...
2
votes
0
answers
341
views
Formatting text the same way knitr formats code, but outside of chunks
Back when I was using sweave, I could make my inline code look like R code by using \texttt{whatever} or \verb@whatever@. I am trying out knitr, and the format of the code chunks sure is pretty. But ...
1
vote
0
answers
3k
views
Error 43 while knitting a markdown to pdf in a R project created on mac and run on Windows
I created a R project which outputs some plots to pdf using rmarkdown::render with an .Rmd file.
I shared the folder when the R project and all the relative files are kept to a colleague using Google ...
1
vote
2
answers
1k
views
With knitr and LaTex, how can you arrange the List of Figures alphabetically?
What code will enable me to reorganize the List of Figures alphabetically (and keep the page number)? My goal is to include that alphabetical listing of figures in the PDF file that is created.
Here ...
1
vote
0
answers
121
views
Knitr Plot Tooltips for ADA Compliance
I would like to use Knitr to generate plots in R that have hover-over tooltips. Here is a working example without an R tooltip:
\documentclass{article}
\usepackage{pdfcomment}
\begin{...
2
votes
1
answer
501
views
knitr code chunks in footnotes
My issue is to include verbatim output from knitr Sweave code chunks in footnotes. The BVerbatim environment (fancyvrb) gives me the formatting that I want. (NB: one needs to put \VerbatimFootnotes ...
1
vote
0
answers
515
views
Extra Curly Braces when creating Xtable using Knitr, after specifiying size
I'm creating a R Markdown document using knitr and am running into trouble using xtable to create a table. My table is very large and I'm trying to reduce the size using the size command in the print ...
11
votes
2
answers
3k
views
Encrypt and decrypt parts of text in a LaTeX source file
Assume that you have some text in parts of your LaTeX document that you only want people with a password to see. A reason could e.g. be a case with an guiding answer. You want to make the case public ...
1
vote
0
answers
131
views
Page margins in .Rtex
I'm using ShareLatex to write my thesis (which relies heavily on R) but the page size changes when I set my document to "main.Rtex" instead of "main.tex". I provide a minimal example so you can check ...
0
votes
1
answer
2k
views
Knitr markdown can't display basic symbols
I'm on Ubuntu 14.04, running RStudio Version 0.99.473. I have LaTeX installed (TeXworks) and knitting Rmarkdown documents works just fine. However, adding mathematical symbols such as $\mu$ causes it ...
4
votes
2
answers
4k
views
Running R code from latex. (alternative to knitr)
If you want to export the output of an R script to latex and create a pdf document you can use the package Knitr with RStudio.
But I guess this is only a good practise for short results.
What if I ...
3
votes
1
answer
672
views
Is it safe to reinstall MacTex after upgrading from Yosemite to El Capitan
I was using MacTex on OSX 10.10 (Yosemite). I upgraded to OSX 10.11 (El Capitan) and now I get the error "No TeX installation detected" trying to compile a latex document using knitr.
I saw the ...
2
votes
1
answer
999
views
knitr texmaker could not start the command
I have recently upgraded to El Capitan and I can't make knitr work with texmaker anymore. I have red all the issue concerning MacTex and the change in the path from /usr to /Library/Tex but here I can'...
3
votes
2
answers
817
views
knitr not working on LyX after installation of Mac OS X El Capitan
I updated my Mac to OS X El Capitan and knitr doesn't work on it. Before the update everything was fine. Now LyX is saying : "The module knitr requires a package that is not available in your LaTex ...
0
votes
0
answers
2k
views
Encoding error when knitr -> LaTeX -> PDF
I have a document written in knitr. I can export it to HTML and docx, but not PDF for some reason. The Rmd file is here http://cl.ly/dJka?_ga=1.30252732.2076817589.1442770201
It says
! Package ...
0
votes
0
answers
313
views
R to LaTeX with knitr and pandoc (error in a guide)
I want to follow the guide http://kieranhealy.org/blog/archives/2014/01/23/plain-text/ since my document http://rpubs.com/lindberg/110268 need to be pushed to latex for a better read.
The tex says "...
2
votes
2
answers
771
views
References and bibliography with knitr, ESS and AUCTEX
I'm trying to get references working in a knitr Rnw document using ESS, AUCTex, TeXLive, and natbib.
Here is a minimal example:
\documentclass{article}
\usepackage{natbib}
\begin{document}
<<...
1
vote
1
answer
522
views
Using knitr with TeXworks
I checked out the conversation between Speravir and Yihui, and also Yihui's site and video for getting knitr to work with TeXworks. However, I am definitely not super tech-savvy and I'm having some ...
2
votes
1
answer
3k
views
Wrap text from xtable row names with knitr
I am using knitr to generate pdfs that contain tables that I'm making with xtable. How can I wrap the text in these tables?
Here is my best effort so far:
\documentclass{article}
\begin{document}
&...
0
votes
0
answers
479
views
How to create tikz figures via knitr forcing labels featuring LaTeX's font size modifier-commands?
Is there a way to force knitr to create tikz code which includes font size information? The output would be something like this:
\begin{tikzpicture}[every node/.style={font=\footnotesize}]
Here is ...
1
vote
1
answer
10k
views
knitr - double spacing in an html document
If my knitr output was a pdf, then I can begin my document as follows to have the text double spaced:
title: My Title
author: "My Name"
date: "Today's Date"
header-includes:
- \usepackage{setspace}...
1
vote
0
answers
774
views
ShareLatex knitr install package
Sharelatex comes with a few R library's that you can query. However, it is impossible for me to install a package or query a non pre-installed package. The package I am trying to use is the arm ...
3
votes
0
answers
1k
views
SOLVED - Knitr/pandoc bibliography problem [closed]
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
1
answer
3k
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 0....
0
votes
0
answers
360
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
1
answer
952
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
1
answer
109
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)
@
...
2
votes
1
answer
532
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);
options("width&...
0
votes
1
answer
1k
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.
\documentclass{...
1
vote
1
answer
709
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
1
answer
3k
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 ...
2
votes
1
answer
8k
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
0
answers
116
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.
\begin{...
10
votes
2
answers
2k
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}
\usepackage{longtable}...
1
vote
0
answers
243
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 ...
2
votes
2
answers
1k
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, include=...
2
votes
1
answer
139
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 ...
1
vote
1
answer
2k
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
1
answer
282
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, ...
4
votes
1
answer
17k
views
what does this error message suggest? [closed]
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: ...
2
votes
1
answer
1k
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 rnw....
2
votes
2
answers
2k
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 ...