Questions tagged [sweave]

Sweave is a function in the statistical programming language R that enables integration of R code into LaTeX or LyX documents.

Filter by
Sorted by
Tagged with
48 votes
6 answers
23k views

Dynamically count and return number of words in a section

I am writing a proposal for which it is required to give the number of words of the main section in the proposal itself. I found this answer on how I can get a word count on a LaTeX document: Is ...
Sacha Epskamp's user avatar
28 votes
2 answers
34k views

Getting Sweave code chunks to stay inside page margins?

Sometimes I get to make an R code chunk (in Sweave) which is longer then the margins of the page. Is there a way to force it to "go to the next line" once that happens? Here is a simple example of ...
Tal Galili's user avatar
  • 1,389
26 votes
2 answers
15k views

How to build Knitr document from the command line

I would like to compile a knitr document from the command line. With Sweave, the sequence R CMD Sweave my_sweave_file.Rnw latex my_sweave_file.tex latex my_sweave_file.tex dvips my_sweave_file.dvi ...
ichbinallen's user avatar
20 votes
2 answers
22k views

Tables with multiple panels in LaTeX, R and Sweave

I would like to know what the accepted Sweave/R/LaTeX solution is for producing tables with "panels": multiple parts, which may or may not contain the same columns, combined into one table. The ...
Matt's user avatar
  • 303
19 votes
2 answers
7k views

Building TeX file from knitr Rnw as child of larger parent TeX file to use R objects and output

Here's my general problem: I'm writing my dissertation using a LaTeX template (http://www.latextemplates.com/template/masters-doctoral-thesis). The template is a parent file with multiple chapters as ...
itpetersen's user avatar
18 votes
5 answers
31k views

Latex Error: 'Sweave.sty' not found?

I downloaded the most recent version of Miktex Basic Installer (2.9.5105). After following the Miktex's instructions, I began working through Nicola Satori's Sweave Tutorial. The R portion of ...
user avatar
18 votes
3 answers
21k views

Using fancyhdr to create an image based header and footer

I'm trying to generate a latex report (via Sweave and R) where the header of the document is an image that covers everything (including the top/left/right page margin) and the footer covers everything ...
Brandon Bertelsen's user avatar
13 votes
2 answers
20k views

longtable misplaced noalign

Question Why am I getting multiple misplaced \noalign errors? Reproducible example \documentclass{scrartcl} \usepackage{longtable} \usepackage{booktabs} \begin{document} \section{Table test} \...
penguinv22's user avatar
13 votes
3 answers
3k views

What do Sweave/knitr offer that make doesn't?

I use LaTeX to write papers and R for data analysis and visualization, so I've been looking into Sweave and knitr. The Sweave website says: The purpose is to create dynamic reports, which can be ...
ff524's user avatar
  • 277
12 votes
4 answers
1k views

Workflow in Sweave: Handling TeX errors

I've been using LaTeX and R for a few years now, but am only now bringing them together via Sweave. As I put the document together, I run my R code in its own session to verify that it works properly, ...
Charlie's user avatar
  • 781
11 votes
1 answer
1k views

Is it possible to get Sweave/knitr in RStudio to output the .tex file without typesetting it?

I would like to know if it is possible to tell Sweave or knitr in RStudio to create the .tex file without trying to typeset it. I want to be able to run my .Rnw file and produce a .tex file which I ...
Kenji's user avatar
  • 617
10 votes
1 answer
14k views

Plots are not appearing in PDF after using Sweave

In general, Sweave is making great looking PDFs for me. However, when I plot a histogram, it is not appearing in my PDF. I have a bare bones Sweave document as follows. I can't seem to isolate ...
tumultous_rooster's user avatar
10 votes
5 answers
4k views

How to get correct dimensions for a ggplot2 plot in beamer

I have a beamer presentation made with Sweave that I'm preparing and was wanting to place some ggplot2 graphs in but the aspect ratio does not seem to come out correct. This is what is in my Rnw file....
Andrew Redd's user avatar
10 votes
3 answers
469 views

What tools are there to make LaTeX more viable at work

I do data mining in R, Python and various object oriented languages. I like using LaTeX to present my results; either to myself (i.e. use them for result interpretation/analysis) or to send to ...
user2763361's user avatar
9 votes
3 answers
4k views

LaTeX techniques and templates for writing a book [closed]

I am about to write a couple of books using LaTeX. I am fairly used to producing small LaTeX articles using Sweave and R, but I have never written a book using LaTeX and I am not conversant with the ...
Soumendra's user avatar
  • 257
9 votes
2 answers
4k views

R, Sweave, Hmisc: pretty-print numbers

I'm creating a LaTeX tables based on a matrix in R using the 'latex' function of the Hmisc package. dat = matrix(c(1000, 100, 10000, 10000), 2) latex(dat, file='') This works (as expected) perfectly....
FloE's user avatar
  • 193
9 votes
3 answers
3k views

Include Sweave input as verbatim

How do I keep Sweave from compiling things in a verbatim environment? For example: \documentclass{article} \begin{document} \begin{verbatim} <<>>= 1+1 @ \end{verbatim} \end{document} ...
Sacha Epskamp's user avatar
9 votes
1 answer
3k views

how to colorize syntax using R + Sweave?

I'm writing a LaTeX document using Sweave (a Beamer presentation, really), which weaves R code and LaTeX. Is there a way to make my chunks of code and its output highlighted? I could use listings ...
Roman Luštrik's user avatar
9 votes
1 answer
3k views

Passing a variable from TeX to R in Sweave

I know it is possible to use \Sexpr to pass information from an R chunk to LaTeX. For example, <<echo=F,results=hide>>= a = 7 @ 42 is the answer to 6 x \Sexpr{a} Is there an ...
Tahnoon Pasha's user avatar
8 votes
1 answer
7k views

side-by-side xtables in Sweave

I use xtable to manage my tables in Sweave like this <<label=tab1, echo = FALSE, results = tex>>= print(xtable(Table1)) @ <<label=tab2, echo = FALSE, results = tex>>= print(...
MYaseen208's user avatar
  • 8,615
8 votes
1 answer
641 views

Having trouble with pgfSweave and tikzDevice

On Ben Bolker's advice I started using pgfSweave and tikzDevice. I'm struggling with getting R graphs into LaTeX. This is my code for pgfSweave Rnw file: \documentclass{article} \usepackage{tikz} \...
MYaseen208's user avatar
  • 8,615
8 votes
1 answer
4k views

FancyVerb error for Sweave output in Beamer

I'm having trouble including Sweave output in my Beamer file. Specifically, the Soutput environment is causing problems (it runs if I comment those lines out, but, of course, the table is not ...
Charlie's user avatar
  • 781
8 votes
1 answer
1k views

Sweave generating invalid LaTeX

I've encountered a problem when I'm using Sweave to convert an .Rnw file into a .tex file. Sweave is replacing three options from hyperref's \hypersetup block with the value NA. This is the section ...
Alastair's user avatar
  • 433
7 votes
2 answers
19k views

Missing character: There is no ? in font cmr12!

I'm not quite sure how to diagnose this issue. This is what I see in my log file. However, there are no "?" symbols in my work. FWIW, Here's my preamble: \documentclass[12pt]{article} \title{Title}...
Brandon Bertelsen's user avatar
7 votes
1 answer
2k views

Remove\begin{Schunk} \begin{Sinput}

I am using Sweave to produce my tex. In addition I use lstlisting to highlight the source code as below. \begin{lstlisting}[caption={Computation $\widehat Y_4$ and its Residue},label=list:...
Satria's user avatar
  • 73
7 votes
1 answer
3k views

Selectively suppress caption numbering when using xtable

I have a chunk of code which is producing table output using Xtable and I would like to suppress the table numbering. I know I can suppress numbering using \caption* outside of Xtable but I'm stumped ...
Trevor's user avatar
  • 171
7 votes
1 answer
15k views

Sweave and Knitr Figure Size

I recently made the switch from using Sweave to Knitr in order to gain Knitr's ability to cache R code chunks. So far its been fairly straightforward except for one thing. I cannot seem to find an ...
JHowIX's user avatar
  • 299
7 votes
0 answers
524 views

Can I import existing .Rnw Sweave file into LyX? [closed]

I am trying to import an existing Sweave .Rnw file into LyX. I wonder whether LyX is capable of doing it? My LyX version is 2.02 and I can use its Sweave module with no problem. I find out it does ...
Vulpecula's user avatar
  • 171
6 votes
4 answers
4k views

Multiple Tables Sweave/Latex

I am very new to LaTeX and Sweave but am excited that it may make my life much simpler when combined with R. What I am looking to do: Create multiple crosstabs, most likely in a loop. As a result, ...
Btibert3's user avatar
  • 183
6 votes
1 answer
3k views

Sweave, Beamer and ggplot2

There's literally nothing on the internet showing how these work in conjunction with one another. I would really appreciate even the simplest example of a Rnw document that you would run with Sweave() ...
Brandon Bertelsen's user avatar
6 votes
1 answer
800 views

Using Sweave and XeLaTeX

I'm doing a report that is heavy in R but also would like to use system fonts, so I was hoping to be able to use Sweave and XeLaTeX. My preferred tex editor is TexShop (Mac 10.7), but it seems to ...
Señor O's user avatar
  • 247
6 votes
6 answers
5k views

How to comment in an R-chunk?

I'm quite new to both R and LaTeX, but I'm trying to work with both, using Sweave. I know you can comment in R using # and in LaTeX by using %. However, when I write a #comment in an R-chunk (between &...
Mien's user avatar
  • 171
6 votes
1 answer
1k views

Best way to display percentages in Sweave?

What is the best way to display percentages in Sweave? A simple example: The number 4 is \Sexpr{4 / 7} of 7. What is the best way to get the document to display: The number 4 is 57.1% of 7.
Boom Shakalaka's user avatar
6 votes
2 answers
2k views

How to prevent text generated with `Sweave` from running off the right margin?

I am using Sweave to generate output for some R analysis. Some of the code generates long lines that are run off the right margin when the .tex file is compiled. I have pasted an example Schunk ...
DQdlM's user avatar
  • 1,733
6 votes
1 answer
531 views

Why are \twoheadleftarrow and \leftarrow so different? [Sweave, listings]

I am wondering why the \twoheadleftarrow in the code below looks so much different from (worse than) the \leftarrow, although according to the LaTeX symbol list, the arrow heads should be of the same ...
Marius Hofert's user avatar
6 votes
1 answer
2k views

Making LaTeX documents with Hebrew? (in Sweave + RStudio)

I would like to write in Hebrew in an .Rnw file, and use it with RStudio. Searching around, I found an example for using Hebrew in LaTeX in general: Numbers, punctuation and parenthesis reversed in ...
Tal Galili's user avatar
  • 1,389
6 votes
2 answers
2k views

Integrate 'Sweave.sty' in the TeXLive 2010 search path (on Linux)

I'd like to add 'Sweave.sty' to my search-path, so that I don't need to copy 'Sweave.sty' to every Sweave-Document I create. I've located 'Sweave.sty' in '/usr/share/R/share/texmf/tex/latex'. I tried ...
Marcel's user avatar
  • 891
6 votes
1 answer
4k views

How to insert references and bibliography into a .Rnw file produce with RStudio R Sweave and knitr?

So far, I have successfully used RStudio and R Markdown to write scientific papers and insert citations from the medical literature without significant problem as shown in the minimal example (MWE) ...
CharlesLDN's user avatar
6 votes
3 answers
2k views

What's the best .Rnw editor?

I'm trying to find out what people use for editing .Rnw files. Desirable features are: Auto R code completion Auto LaTeX code completion Cross platform Automatic display of R function documentation ...
kennyB's user avatar
  • 459
6 votes
1 answer
2k views

How to sweave Matlab or Mathematica code into LaTeX.

There is a package called pgfsweave for R. It can sweave R code into a LaTeX document. I found we can gain some advantage from this method. The report document can reproduce. The font in figure ...
pythonee's user avatar
  • 2,567
6 votes
2 answers
2k views

Supplying string parameters to Sweave document

This must be a simple question but I don't figure out how I can do it. I would like to produce a pdf report using Sweave. And actually, many many reports. I shortened and simplified the sweave code ...
tony's user avatar
  • 161
6 votes
1 answer
10k views

Controlling formatting options for xtable

All, I'm a LaTex/knitr/Sweave amateur and have had trouble finding answers to what seem like they should be fairly simple questions online. I have a .Rnw script that I am currently compiling to PDF ...
aaron's user avatar
  • 265
6 votes
1 answer
2k views

How to randomize content with examdesign package using Sweave

Forgive me in advance if this is a dumb question, or too specific to one package. I've been using examdesign to randomize the order of questions, but I also want to randomly generate the content. I've ...
Dustin Fife's user avatar
6 votes
0 answers
2k views

Color first row in a xtable generated table [closed]

I am trying to color the FIRST row of my table. But if I add \rowcolor[gray]{0.95} to the FIRST row the colored row will be the SECOND. Indeed it is quite straight forward to modify from the second ...
Francesco's user avatar
  • 4,604
5 votes
2 answers
2k views

How to label a code section in Sweave

I'm new to sweave and was wondering what is the appropriate way to label a code section. For example, if I have: <<echo= true>>= x<-5 y<-x+5 @ How would I get it to put a either ...
user1357015's user avatar
5 votes
2 answers
5k views

how do you put caption on figures in sweave

I have this sweave code. I need to add caption to the figures. I am doing this but it looks like I see the figure before the section{Data ANALYSIS}: \documentclass[letter,12pt]{article} \...
user1471980's user avatar
5 votes
4 answers
2k views

Auctex TOC with multifile document

I'm writing my PhD thesis with LaTeX-Sweave and I use EMACS with AucTex and ESS. I have a master file (master.tex) and some slave files and my question is about the use of the TOC in the slave files. ...
Ricca's user avatar
  • 51
5 votes
1 answer
1k views

How to check image exists or not?

I'm working on Sweave and using includegraphics for include image in report dynamically. Pseudocode: <<> for ( i to 100) # run loop 1 to 100 { includegraphics(image....
manish's user avatar
  • 9,101
5 votes
3 answers
1k views

Sweave Multiple Chapters

I am writing a large Sweave document that will be broken up into many chapters with the final output being a large pdf of everything and an individual pdf for each chapter (with the same page and ...
Jared's user avatar
  • 171
5 votes
1 answer
3k views

Reducing R figure sizes in lyx?

I am using LyX with the Sweave module to generate some R figures within a document. I can't seem to get the figures to be smaller, and they tend to take up half a page which is far too large. I have ...
user avatar

1
2 3 4 5