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

learn more… | top users | synonyms

3
votes
1answer
4k views

Reinstalling LaTeX in Ubuntu 13.04 [duplicate]

The LaTeX in my system cannot support Sweave compilation to pdflatex, it warns for missing .sty files. I want to clean my system and reinstall a more complete LaTeX. What is the better way for doing ...
3
votes
1answer
222 views

Is there a PythonTex equivalent to \Sexpr{} in R?

I started to use the excellent PythonTex package to write reproducible reports but can't seem to get it to evaluate Python code inside a LaTeX command. R has Sweave & knitr which provide the ...
2
votes
1answer
78 views

Sweave.sty causing error in verbatim environment?

folks-- The following throws an error, shown below \documentclass{book} \usepackage{Sweave} \begin{document} \begin{verbatim} data ds; infile 'dir_location\filename.csv" ...
3
votes
1answer
150 views

Sweave outputs gibberish

I have this .Rnw file: \documentclass{article} \begin{document} <<>>= data(cars) fit <- lm(cars$speed~cars$dist) summary(fit) @ \end{document} I am using RStudio to build the PDF ...
2
votes
2answers
1k views

Installing Sweave for Miktex 2.9 on Windows 7

I've been looking everywhere, but my computer (Windows 7) just won't install the Sweave.sty package for Miktex 2.9. I tried to put it in a folder respecting the TDS standard, and then to install it, ...
2
votes
1answer
282 views

insert figure in sweave using knitr fig.path

I'm trying to insert a figure using Sweave which is located in the path C:\Users\eccehomo\Documents\mi\fig1.png. I'm using the package knitrwhich has a function called fig.pathbut I'm getting many ...
1
vote
1answer
166 views

How to print a system of linear equations in matrix form using sweave?

I would like to print a system of linear equations, a right bracket, a right arrow and finally the output of the system (x). Something like Ax = b } ---> x. It is hard for me to find the right way of ...
1
vote
0answers
42 views

Citations not working in Sweave [duplicate]

I am trying to run this Sweave code in R. \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} \section{Section} I am citing \cite{ftest}. \begin{thebibliography}{9} ...
2
votes
1answer
232 views

\Sexpr shows only one value from a vector with two elements in sweave

I can't get the two elements of the vector using: <<>>= z=c(1,2) @ \Sexpr{z} I have googled a lot but don't understand why I get just the first element.
3
votes
1answer
102 views

Why could \usepackage{Sweave} be affecting my graphics scaling?

I'm using Sweave to produce a large, multi part academic thesis. I had neglected to specify \usepackage{Sweave} in my preamble, but everything was working fine until I added some verbatim output from ...
2
votes
1answer
198 views

Doodle on top of Sweave output

It might not be possible to do this, but I was wondering if there is a way to doodle on top of the LaTeX output, or in my case on top of Sweave output. See example underneath!! ...
1
vote
0answers
72 views

Figure positioning in Sweave [duplicate]

I starting learning Sweave today, and I am having difficulty positioning my figures correctly. I am finding that when I use the figure environment, the position of the figure doesn't correspond to its ...
0
votes
0answers
85 views

Count the characters in a section and check against range

I want to count the number of characters within a section and then display if that value is below, in, or above the limit. I have grabbed the code from Dynamically count and return number of words in ...
2
votes
1answer
149 views

PDFLaTeX produces black boxes after executing Sweave

There is the following code \documentclass[a4paper]{article} \begin{document} hey there <<>>= 1+1 @ \end{document} I saved the example.Rnw in my home directory an ...
0
votes
2answers
463 views

Sweave: run a bat file in Windows 7

When I run a RNW file inside RStudio compilation is working. But when I try to run the same RNW file through a BAT file, compilation is not working. I am a Win 7 user, using MixTex... Actually my ...
5
votes
1answer
164 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 { ...
0
votes
2answers
218 views

How to remove name while including image in LaTeX?

I am including an image in R and found the name of the image file appearing with the image: name<-c("A.pdf","B.pdf","C.pdf","D.pdf") <<echo=FALSE,results=tex>>= for (i in 1:4) ...
1
vote
2answers
235 views

Sweave documents: saving output for later use

I am fairly new to the idea of sweave documents. My document is a .Rnw file containing LaTeX code and R code. Part of my R code is computationally intensive and delays the compilation of my .Rnw ...
5
votes
1answer
258 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 ...
4
votes
1answer
152 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 ...
2
votes
2answers
431 views

minted: How to pass LaTeX commands via \newminted and how to use different styles?

I would like to use minted to redefine the Sweave environments Sinput and Soutput (see the example below). This way, I can have minted format my R code. There are two problems left: 1) Is it possible ...
1
vote
1answer
136 views

Sweave: How to remove horizontal space in Soutput environments?

As the following example shows, there is a horizontal space added in the Soutput environment. This leads to a non-left-aligned output (see the output of rnorm(). I found that this space already exists ...
5
votes
1answer
469 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 ...
6
votes
1answer
558 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 ...
1
vote
1answer
705 views

Sweave and Matrix

I am using xtable to generate Matrices x1mean <- matrix(c(204.5, 556.5), 2) x2mean <- matrix(c(130.0, 355.0), 2) x1mmat <- xtable(x1mean, align = rep( "", ncol(x1mean) + 1) ) x2mmat <- ...
0
votes
1answer
123 views

Question mark in knitr code getting quote marks [closed]

I'm trying to use question marks in a code block using knitr, but in the compiled pdf always puts quotes around it, so, for example <<helpCode, eval=FALSE>>= ?rnorm @ comes out as ...
2
votes
2answers
178 views

Sweave, how to suppress opening new instance of a pdf when running pdflatex

Since I have setup SumatraPDF to automatically refresh PDFs when they change, how can I suppress "view" (resulting in opening a new instance of the pdf) when using the shortcut M-n P (running ...
1
vote
1answer
246 views

How to obtain Sweave(l) listings with rounded corners?

I downloaded the Sweavel.sty-File from here: http://biostat.mc.vanderbilt.edu/wiki/pub/Main/SweaveTemplate/Sweavel.sty Now, for a modern look, I would like to produce rounded corners in the R code ...
0
votes
1answer
683 views

Looping a code-chunk in LaTeX

I want to generate a report for three types of analysis I am performing. But each time when I perform the analysis it can happen that one or more than one type of analysis occur. I want to put ...
5
votes
1answer
121 views

Sweave Float environment over 2 pages

I have a bit of Sweave code as such: <<label = Example1, echo= true>>= //Bunch of R Code @ I've tried putting it in my own float environment like so \newfloat{rcode}{h!}{rcode} ...
5
votes
2answers
318 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 ...
3
votes
2answers
3k views

How to teach latex to find Sweave.sty? [Ubuntu 12.04; TeXLive 2011]

I work on XUbuntu 12.04 and I have installed R 2.15. Since the package manager only provides TeX Live 2009, I use the following to install TeX Live 2011 on XUbuntu: download install-tl-unx.tar.gz ...
2
votes
1answer
217 views

Rstudio output in Hebrew

(Follow-up to Making LaTeX documents with Hebrew? (in Sweave + RStudio)) Trying to reproduce the above answer, I followed these instructions without success, under Windows 7. The best result I got ...
2
votes
1answer
458 views

Sweave.sty Rd.sty on texlive 2011 (OpenSUSE 12.1)

I am trying to make Sweave.sty and Rd.sty globally available on my system. After reading related posts on StackExchange, I changed texmf.cnf, so that kpsewhich --expand-var='$TEXMF' results in ...
1
vote
1answer
187 views

Explain Soutput Schunk -block when switched from article to scrreprt

When I zwitched from article to \documentclass[fontsize=2pt]{scrreprt}, I am getting around the xtable -things: \begin{Schunk} \begin{Soutput} ... \end{Schunk} \end{Soutput} Trial (code here) $ R ...
6
votes
6answers
1k 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 ...
5
votes
3answers
477 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 ...
1
vote
1answer
132 views

Using toggles from etoolbox to switch Sweave Schunks of code on and off

I would like to use the toggles from etoolbox to direct Sweave to evaluate or not evaluate chunks of code. Example: \newtoggle{FirstTime} \toggletrue{FirstTime} %\togglefalse{FirstTime} ...
1
vote
2answers
240 views

LaTeX/Sweave - How to reproduce code blocks in an appendix?

I hope this is in the right place. For my statistics assignments, I do the computation inline with Sweave, like so: \begin{itemize} \item[Problem 1] <<label=block1,eval=T,echo=F>> ...
0
votes
1answer
968 views

How to disable null device while usin dev.off() in R and latex?

How to disable message null device when using R and latex. <<echo=FALSE ,results=tex>>= data<-read.table("test",sep="\t",header=TRUE,check.names=FALSE) ...
1
vote
1answer
382 views

Adjust line numbers in error messages

Question Is there any way I can alter the line-numbers reported by TeX and friends in error messages? This is almost an identical question to Add offset to line number (in error message) when using ...
8
votes
3answers
3k 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 ...
2
votes
1answer
465 views

Yasnippet, Sweave: How to make snippets work from .Rnw files?

I use yasnippet's defined in ~/.emacs.d/plugins/yasnippet-0.6.1c/snippets/text-mode/latex-mode to insert small pieces of code when working with LaTeX. I recently started to use Sweave and therefore ...
1
vote
1answer
3k views

LaTeX Error: Illegal character in array arg using apsrtable in R

I am using sweave in R-Studio and am attempting to use the R package apsrtable. Both the model objects I am passing apsrtable are lm objects, and I get the error illegal character in array arg ...
2
votes
1answer
858 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 ...
8
votes
2answers
2k 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) ...
4
votes
1answer
778 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 ...
0
votes
1answer
632 views

LaTeX, Sweave: How to get \upshape (or \rm) in lines which display code?

How can get an upshape font (\rm) [with Sweave] in lines which display code (such as 1:300 + runif(300)) below? I tried a couple of things (I found fontshape=n online), but they did not influence the ...
2
votes
2answers
2k 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} ...
4
votes
0answers
323 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 ...