[R] Sweave: Howto write real TeX formula in plot

cls59 sharpsteen at mac.com
Fri May 15 02:48:00 CEST 2009



Bugzilla from news at jonasstein.de wrote:
> 
> Thank you, Baptiste and Charlie.
> I found some examples wich look great on:
> http://www.texample.net/tikz/examples/
> 

I'm glad you found Texample! It is an excellent site that shows many
practical, and beautiful, demonstrations of the types of figures that can be
constructed using LaTeX.
 


Bugzilla from news at jonasstein.de wrote:
> 
> 
> I have installed pgf with apt-get install pgf. That worked fine, but
> installing pgfSweave fails.
> 
> I did this:
> 
> ,----[ in R interpreter (running as root) ]
> | 
> | install.packages('pgfSweave',,'http://www.rforge.net/') 
> | 
> | Warning in install.packages("pgfSweave", , "http://www.rforge.net/") :
> |   argument 'lib' is missing: using '/usr/local/lib/R/site-library'
> | trying URL 'http://www.rforge.net/src/contrib/pgfSweave_0.7.1.tar.gz'
> | Content type 'application/x-tar' length 1017992 bytes (994 Kb)
> | opened URL
> | ==================================================
> | downloaded 994 Kb
> | 
> | * Installing *source* package 'pgfSweave' ...
> | ** R
> | ** exec
> | ** inst
> | ** preparing package for lazy loading
> | Loading required package: stashR
> | Warning in library(pkg, character.only = TRUE, logical.return = TRUE,
> lib.loc = lib.loc) :
> |   there is no package called 'stashR'
> | Error: package 'stashR' could not be loaded
> | Execution halted
> | ERROR: lazy loading failed for package 'pgfSweave'
> | ** Removing '/usr/local/lib/R/site-library/pgfSweave'
> | 
> | The downloaded packages are in
> |         /tmp/Rtmp6huu9t/downloaded_packages
> | Warning messages:
> | 1: In install.packages("pgfSweave", , "http://www.rforge.net/") :
> |   dependencies ‘stashR’, ‘filehash’, ‘digest’, ‘cacheSweave’ are not
> available
> | 2: In install.packages("pgfSweave", , "http://www.rforge.net/") :
> |   installation of package 'pgfSweave' had non-zero exit status
> |
> `----
> 
> what will i have to do now?
> 
> 


pgfSweave was created by modifying another package called cacheSweave.
cacheSweave uses the digest, filehash and stashR packages to store the
results of code chunk computations. If a code chunk for which caching has
been enabled is not changed between Sweave compilations pgfSweave and
cacheSweave load stored variable values from the cache files instead of
recomputing them. This hopefully saves time when all you want is to try out
a different figure header or placement, not redo a whole Monte Carlo
simulation.

The problem is that rforge.net, which hosts the pgfSweave project, does not
have these other packages. The easiest way around this is to install
cacheSweave from CRAN since the dependencies are the same:

install.packages('cacheSweave',dependencies=T)

Then install pgfSweave:

install.packages('pgfSweave',repos='http://www.rforge.net')



Bugzilla from news at jonasstein.de wrote:
> 
> 
> And could someone give me an example how to write a formula in a plot?
> Like plot(... title="$\sigma^2 + \int x$")
> 
> 

The example you gave will work perfectly for inserting math into a plot
title when using pgfSweave. The only modification is that backslashes have
to be escaped so that they aren't interpreted by R as control characters.
For example, you will need to use \\sigma and \\int. For direct annotation
of a plot, you might consider the text() function which can be used to add
labels and formulae at any arbitrary location.

Good luck!

-Charlie


-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: http://www.nabble.com/Sweave%3A-Howto-write-real-TeX-formula-in-plot-tp23127536p23551596.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list