Re: [R] LaTeX in R

From: Mario Maiworm <mario.maiworm_at_uni-hamburg.de>
Date: Fri, 07 Mar 2008 17:02:04 +0100

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.
>>> >



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. Received on Fri 07 Mar 2008 - 16:06:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Mar 2008 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive