### Post

1 follower Follow

# How to use RStudio with Sweave?

Hello,

I imagine this is kind of a huge question, but here goes -
I do not know LaTeX or SWeave, but would like to have a workflow using RStudio (on windows) and these tools.
What do I need to install? What manuals should I consult?

Thank you for any suggestion.
Best,
Tal

Ian Pylvainen

### 7 comments

Tal,

Glad to hear you want to learn LaTeX and Sweave. You'll find them to be a great resource and nice addition to using R. The full answer to your question is rather verbose, but (on Windows) I would start by downloading and installing TeX through MikTeX:

http://miktex.org/2.9/setup

After this, consult some online resources and just start a new file in RStudio: File | New | TeX Document. Play around and create your first document. Here is a decent reference for TeX and the standard demo example for Sweave:

Sweave Demo - http://www.stat.umn.edu/~charlie/Sweave/foo.Rnw
Website Reference - http://www.stat.umn.edu/~charlie/Sweave/

Also here is the skeleton of a very basic TeX document (you can copy and paste this into RStudio, save, and run it).

\documentclass{article}
\begin{document}

Hello World

\end{document}


For Sweave, here is the link to the website and manual:
Website: http://www.stat.uni-muenchen.de/~leisch/Sweave/
Manual: http://www.stat.uni-muenchen.de/~leisch/Sweave/Sweave-manual.pdf

Hope this helps get you started!

Josh

Ian Pylvainen 0 votes

Hi Josh,
Thank you for the reply - your encouragement is much appreciated.

I see there are several "issues" which I'd be happy to know if they might be met:

1) Can the file be compiled into HTML (or RTF)? If so, how? (in the short run, how might I do it manually? In the long run - could you add it as a feature?)
This is highly important for me, since I need to communicate my analysis to researchers who work with Word.

2) The "compile PDF" doesn't seem to work for Hebrew text.
I get an empty document when running something like -

\documentstyle{article}
\begin{document}
Hello world
שלום עולם
\end{document}

I tried some of the various encoding and non seemed to work for me. Is there a way to run all of the possible encoding so to find the one that would work?
BTW, "iso8859-8" sometimes work in R, but it didn't work for this case.

Thanks again Josh :)

Ian Pylvainen 0 votes

Tal,

1) I'll add it to our feature request list and I am almost sure you can do this manually, but personally don't know how. latex2html seems promising, but I haven't tried it.

http://www.latex2html.org/

If you figure it out, please update me.

2) Is this a TeX issue or RStudio? My guess would be TeX, but can you try compiling such a document outside of RStudio (from the terminal or within MikTeX) and see if it has the same result.

3) Not sure how to run all permutations of encoding, but my guess is a google search might lead you to the right answer.

Josh

Ian Pylvainen 0 votes

Hi Josh,

o.k., I've played around with it a bit more.

1) I'd like to emphasize the importance of this. Being able to Sweave something into HTML (either from LaTeX or even HTML markup) will be useful. Haveing the Sweave written in HTML markup turned into HTML is easy through the use of:
library(R2HTML)
Sweave('temp1.rnw', driver = RweaveHTML)
And having the ability to easily run it from the "compile PDF" button would be nice.

2-3) The Hebrew indeed was a TeX problem.
Using the example from here worked:
http://www.sciencebits.com/HebrewOnTexShop
However, when mixing this code with other types of code, problems seem to arise...

p.s: The "file" tab seems to forget where it was when re-opening RStudio.
p.p.s: when is the next release scheduled? I'm looking forward to the git integration :)

Ian Pylvainen 0 votes

Tal,

Great and thanks for the additional details, definitely appreciate the resources. Not sure what else to do for integrating Hebrew into TeX, bu let us know if you have additional information, ideas, or something we need to look into.

Also can you explain the "file tab seems to forget" a little more? Just want to make sure I file a bug properly for this. And the next release will be coming out a little later this year. We don't have a specific date for this, but you'll definitely hear about it.

Josh

Ian Pylvainen 0 votes

Hi Josh,

Regarding TeX and Hebrew - I don't think you have much to add (except maybe allowing for right-to-left editing in the editor.)
One more thing that might improve on the editor - is also allowing for Sweaving of other languages (such as HTML, ascii and the likes). And I am not even talking about extending the editor to enable TeX completion just like the R completion (or at least completing the <<>>= @ sign...) - but all of these ideas are probably of lower priority.

Regarding the file tab - let's say I navigate to a folder in the file's tab. If I would then restart RStudio - I won't see the same file location, but go back to the "home" folder location. Some history of the folders, or favorite folders, or "memory" of the folder location (so the same location will be shown when RStudio is restarted) - would be nice...

Also, I don't write it as much as I would like (since it becomes somewhat redundant), but I really love your product. I recently started (finally) to use it on a regular basis, and I am loving it!

Ian Pylvainen 0 votes