sweave

Recommendations for developing Sweave documents

I'm looking to streamline my Sweave document creation, and I'd like to hear about people's current setups. I feel like the holy grail goes something like this: Editing Rnw code on one half of the screen Single keybinding compiles Sweave document and runs pdflatex View PDF on the other half of the screen; once compiled, PDF is refres...

How can I produce report quality tables from r ?

If I have the following dataframe called result > result Name CV LCB UCB 1 within 2.768443 1.869964 5.303702 2 between 4.733483 2.123816 18.551051 3 total 5.483625 3.590745 18.772389 > dput(result,"") structure(list(Name = structure(c("within", "between", "total" ), .rk.invalid.fields = list(), .Label = charac...

Associate .Rnw with vim latex suite

This I am sure is really basic stuff. I am just beginning using gvim and latex-suite. However I would like latex-suite to load when I edit a sweavefile with.Rnw extension. my .vimrc looks like this " These settings are needed for latex-suite filetype indent on filetype plugin on filetype on let g:tex_flavor='latex' set grepprg=grep\ -n...

emacs, auctex, noweb-mode - how to keep screen from recentering around point?

When in auctex and noweb-mode (using Sweave in emacs), I find it distracting when the screen recenters itself as I use next-line, previous-line, etc. (C-n, C-p, and mouse-1). Does anyone know how to turn it off? Thanks much! ...

losing stdout in R console on Mac OS X

I'm working on a big Sweave document/script on a Mac OS X system, R version 2.9.2. Under some circumstances, it appears as if Sweave is redirecting stdout, so that x <- 1; print(x) gives nothing at all. (The console is still running, as plot(x) pops up a plot as normal.) So, two questions: How do I force stdout to go back to the consol...

Buffer-local variables with Emacs and Sweave

I'm using Emacs 23.1 with ESS 5.4 to edit an Sweave file. I'd like to turn off the default AUCTeX indentation behavior in the buffer (to avoid annoyances with code chunks contained in itemized lists), so at the top of the file I have % -*- LaTeX-indent-level: 0; LaTeX-item-indent: 0; -*-. When I open the buffer and run C-h v LaTeX-inde...

Sweave for python

I've recently started using Sweave* for creating reports of analyses run with R, and am now looking to do the same with my python scripts. I've found references to embedding python in Sweave docs, but that seems like a bit of a hack. Has anyone worked out a better solution, or is there an equivalent for python I'm not aware of? * Swea...

Rreport/LaTeX quality output package

I'm looking for some LaTeX template for creating quality output. On R-bloggers I've bumped on Frank Harrel's Rreport package. Due to my quite modest LaTeX abilities, only a user-friendly (and noob-friendly) interface should suffice. Here's a link to an official website. I'm following the instructions, but I cannot manage to install an ap...

R code in Sweave

Hi guys, I have a scientific paper under review, and a referee asked for my R code to be provided as a Sweave document. I've never heard of Sweave before, do you know what's the better way to do it? Thanks a lot :-) ...

Programming R/Sweave for proper \Sexpr output

Hi I'm having a bit of a problem programming R for Sweave, and the #rstats twitter group often points here, so I thought I'd put this question to the SO crowd. I'm an analyst- not a programmer- so go easy on me my first post. Here's the problem: I am drafting a survey report in Sweave with R and would like to report the marginal return...

Sweave/R - Automatically generating an appendix that contains all the model summaries/plots/data profiles from an analysis

I like the idea of making research available at multiple levels of detail i.e., abstract for the casually curious, full text for the more interested, and finally the data and code for those working in the same area/trying to reproduce your results. In between the actual text and the data/code level, I'd like to insert another layer. Name...

Is it possible to include a Sexpr before the expression has been evaluated in Sweave / R ?

Hello, I'm writing a Sweave document, and I want to include a small section that details the R and package versions, platofrms and how long ti took to evalute the doucment, however, I want to put this in the middle of the document ! I was using a \Sexpr{elapsed} to do this (which didn't work), but thought if I put the code printing ela...

How to put a newline into a column header in an xtable in R

I have a dataframe that I am putting into a sweave document using xtable, however one of my column names is quite long, and I would like to break it over two lines to save space calqc_table<-structure(list(RUNID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), ANALYTEINDEX = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), ID = structur...

how do you loop over a global variable in Sweave

I have a big Sweave file with a variable called "specialty" near the top. The rest of this file is Latex and R, and uses this variable. How can I loop over various values for "specialty"? Two possibilities are: Make the file be one big loop (and convert the Latex parts to R). Write a script that copies the Sweave file, replace the va...

How to include multiple tables programmaticaly into a Sweave document using R

Hello, I want to have a sweave document that will include a variable number of tables in. I thought the example below would work, but it doesn't. I want to loop over the list foo and print each element as it's own table. % \documentclass[a4paper]{article} \usepackage[OT1]{fontenc} \usepackage{longtable} \usepackage{geometry} \usepac...

emacs editing Rnw keep region highlighted when highlighting R chunk

Hello, When editing an Rnw file in Emacs, I often want to make the region cover a chunk of text that contains an R chunk. For a simple example, ewr <<>>= @ wer I use transient-mark-mode such that the region is highlighted. But, if I put the point on the first line and hit C-SPC, then use C-n to move the point down, the highlighting...

Sweave can't see a vector if run from a function ?

I have a function that sets a vector to a string, copies a Sweave document with a new name and then runs that Sweave. Inside the Sweave document I want to use the vector I set in the function, but it doesn't seem to see it. (Edit: I changed this function to use tempdir(() as suggested by Dirk) I created a sweave file test_sweave.rnw...

ESS/AucTeX/Sweave integration

I'm using GNU/Linux distro (Arch, if that's relevant), Emacs v23.2.1, ESS v5.9 and AucTeX v11.86. I want to setup AucTeX to recognize .Rnw files, so I can run LaTeX on .Rnw files with C-c C-c and get .dvi file automatically. I reckon it's quite manageable by editing .emacs file, but I still haven't got a firm grasp on Elisp. Yet anoth...

Displaying errors with sweave

I'm writing some R notes with Sweave and would like to show common errors. For example, <<echo=TRUE, eval=TRUE>>= x = 5 #Case matters! x*X @ However when sweaving, the document won't compile due to the R error. Is there any way to make sweave compile and show the (nicely formated) error? ...

Getting Started with Sweave, Eclipse, and R

Hi All, I am very new to LaTex and R, but I am learning on a daily basis. I really am getting into using Eclipse and want to join the party and start automating my work using Sweave; I am excited for the prospects. That said, I followed Jeromy's post here and think (keyword, think) that everything is set up correctly. However, since ...