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

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue May 12 22:21:09 CEST 2009



Jonas Stein wrote:
> Thank you, Baptiste and Charlie.
> I found some examples wich look great on:
> http://www.texample.net/tikz/examples/
> 
>  
>>> Perhaps try the pgfSweave package on r-forge?
>>> http://r-forge.r-project.org/projects/pgfsweave/> 
>> [..]
>> accomplished using the java utility eps2pgf and requires the PGF/TiKZ
>> package for LaTeX:
>> http://sourceforge.net/projects/pgf/
> 
> 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?
> 
> And could someone give me an example how to write a formula in a plot?
> Like plot(... title="$\sigma^2 + \int x$")

See ?plotmath

then you will find:

plot(1, main = expression(sigma^2 + integral(x)))

Uwe Ligges




> Thank you very much,
>




More information about the R-help mailing list