[R] LaTeX in R
Mario Maiworm
mario.maiworm at uni-hamburg.de
Fri Mar 7 17:02:04 CET 2008
Finally, this should work for an array of sigmas. I just realized that the
substitute()-command is not evaluated within a c()-environment :(
mySigma[1] <- 2; mySigma[2] <- 3;
plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l') ;
lines(dnorm(1:10,sd = mySigma[2]),lty = 2);
legend(x = "topright", lty = c(1,2),legend = c(substitute(sigma == myS,
list(myS = mySigma[1])),substitute(sigma == myS, list(myS = mySigma[2]))))
Mario.
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology
University of Hamburg
Von-Melle-Park 11
D-20146 Hamburg
Tel.: +49 40 42838 3515
Fax.: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
__________________________________________________________________
>>> -----Ursprüngliche Nachricht-----
>>> Von: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de]
>>> Gesendet: Freitag, 7. März 2008 16:30
>>> An: Mario Maiworm
>>> Cc: r-help at r-project.org
>>> Betreff: Re: AW: [R] LaTeX in R
>>>
>>>
>>>
>>> Mario Maiworm wrote:
>>> > Thank you, uwe and jeremy. I was actually looking exactly for that!
>>> But
>>> > something still doesn't work:
>>> > I want to plot a symbol in a legend of a plot, lets say "\sigma = 2".
>>> 2
>>> > should be the value of a variable. So, when I try
>>> >
>>> > mySigma=2;plot(1:10,dnorm(1:10,sd=mySigma),type='l')
>>> > legend(x="topright",legend=paste(expression(sigma)," =
>>> ",mySigma),lty=1)
>>> >
>>> > , the sigma is not plotted as a symbol. This version:
>>> >
>>> > mySigma=2;plot(1:10,dnorm(1:10,sd=mySigma),type='l')
>>> > legend(x="topright",legend=expression(paste(sigma," =
>>> ",mySigma)),lty=1)
>>> >
>>> > gives me a 'real' sigma but the mySigma variable is not evaluated. Any
>>> > ideas?
>>>
>>> Yes:
>>>
>>>
>>> mySigma <- 2
>>> plot(1:10, dnorm(1:10, sd = mySigma), type='l')
>>> legend(x = "topright", lty = 1,
>>> legend = substitute(sigma == myS, list(myS = mySigma)))
>>>
>>>
>>> Uwe Ligges
>>>
>>>
>>> > Mario.
>>> >
>>> > __________________________________________________________________
>>> >
>>> > Mario Maiworm
>>> > Biological Psychology and Neuropsychology
>>> > University of Hamburg
>>> > Von-Melle-Park 11
>>> > D-20146 Hamburg
>>> >
>>> > Tel.: +49 40 42838 3515
>>> > Fax.: +49 40 42838 6591
>>> >
>>> > http://bpn.uni-hamburg.de/Maiworm_e.html
>>> > http://cinacs.org
>>> > __________________________________________________________________
>>> >
>>> >>>> -----Ursprüngliche Nachricht-----
>>> >>>> Von: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de]
>>> >>>> Gesendet: Freitag, 7. März 2008 15:27
>>> >>>> An: Mario Maiworm
>>> >>>> Cc: r-help at r-project.org
>>> >>>> Betreff: Re: [R] LaTeX in R
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> Mario Maiworm wrote:
>>> >>>>> Dear Rers,
>>> >>>>> I understand that I can include R-code in LaTeX using Sweave. Is
>>> there
>>> >>>> a way
>>> >>>>> to do it the other way round? Particularly, I need some TeX
>>> symbols in
>>> >>>> the
>>> >>>>> legend of an R-plot. This can be done in matlab easily, so I am
>>> >>>> optimistic
>>> >>>>> with R. Any suggestions for a command or package?
>>> >>>> See ?plotmath
>>> >>>>
>>> >>>> Uwe Ligges
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>> Best,
>>> >>>>> Mario.
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> __________________________________________________________________
>>> >>>>>
>>> >>>>> Mario Maiworm
>>> >>>>> Biological Psychology and Neuropsychology
>>> >>>>> University of Hamburg
>>> >>>>> Von-Melle-Park 11
>>> >>>>> D-20146 Hamburg
>>> >>>>>
>>> >>>>> Tel.: +49 40 42838 3515
>>> >>>>> Fax.: +49 40 42838 6591
>>> >>>>>
>>> >>>>> http://bpn.uni-hamburg.de/Maiworm_e.html
>>> >>>>> http://cinacs.org
>>> >>>>>
>>> >>>>> ______________________________________________
>>> >>>>> R-help at r-project.org mailing list
>>> >>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> >>>>> PLEASE do read the posting guide http://www.R-project.org/posting-
>>> >>>> guide.html
>>> >>>>> and provide commented, minimal, self-contained, reproducible code.
>>> >
More information about the R-help
mailing list