Re: [R] latex() hangs R console

2010-12-08 Thread Michael Friendly

On 12/7/2010 9:35 PM, Yihui Xie wrote:

shell(paste(yap, C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi))
I can confirm that using shell() directly on the .dvi file generated by 
latex() works, while system() does not -- it hangs

as before.

However, Yihui's patch, in this form still hangs, so maybe there is 
something else going on here.


`show.dvi` -
function (object, width = 5.5, height = 7)
{
viewer - optionsCmds(xdvi)
cmd - if (viewer == yap) {
paste(viewer, object$file)
}
else if (viewer == kdvi) {
paste(viewer, object$file)
}
else if (viewer == xdvi) {
paste(viewer,  -paper , width, x, height, in -s 0 ,
object$file, sep = )
}
else {
paste(viewer, object$file)
}
if (.Platform$OS.type == 'windows') system = shell
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) - environment(latex)



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@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] latex() hangs R console

2010-12-07 Thread Michael Friendly

[Env: R 2.11.1, Win Xp, Miktex 2.7]

I've just started using Hmisc::latex and friends, and find that running 
latex() produces the .tex and .dvi files, but hangs,

presumably trying to run yap.  An example is below.  What could be wrong?

My PATH seems OK:
 strsplit(Sys.getenv(path),';')
$path
 [1] c:\\program files\\imagemagick-6.4.4-q16   
c:\\Rtools\\bin
 [3] c:\\Rtools\\perl\\bin  
c:\\Rtools\\MinGW\\bin
 [5] C:\\Program Files\\MiKTeX 2.7\\miktex\\bin 
C:\\WINDOWS\\system32
 [7] C:\\WINDOWS
C:\\WINDOWS\\System32\\Wbem
 [9] C:\\Program Files\\Intel\\DMIX 
C:\\Program Files\\ATI Technologies\\ATI.ACE\\
[11] C:\\Program Files\\Common Files\\Roxio Shared\\DLLShared\\ 
C:\\WINDOWS\\system32\\nls
[13] C:\\WINDOWS\\system32\\nls\\ENGLISH
C:\\Program Files\\SecureCRT\\
[15] C:\\Program Files\\IDM Computer Solutions\\UltraEdit-32
C:\\Program Files\\SAS\\Shared Files\\Formats
[17] C:\\Program Files\\Graphviz2.20\\Bin   
C:\\Program Files\\MATLAB\\R2008a\\bin
[19] C:\\Program Files\\MATLAB\\R2008a\\bin\\win32  
C:\\Program Files\\TortoiseSVN\\bin
[21] C:\\Program Files\\HTML Help Workshop  
C:\\Program Files\\QuickTime\\QTSystem\\


Example:

 x - matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','this 
that')))

 latex(x, file=)
% latex.default(x, file = )
%
\begin{table}[!tbp]
 \begin{center}
 \begin{tabular}{lrrr}\hline\hline
\multicolumn{1}{l}{x}\multicolumn{1}{c}{c}\multicolumn{1}{c}{d}\multicolumn{1}{c}{this 
that}\tabularnewline

\hline
a$1$$3$$5$\tabularnewline
b$2$$4$$6$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}

 cd(c:/r/test)
 latex(x)
This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.tex
LaTeX2e 2005/12/01
Babel v3.8l and hyphenation patterns for english, dumylang, 
nohyphenation, ge

rman, ngerman, french, loaded.
(C:\Program Files\MiKTeX 2.7\tex\latex\base\report.cls
Document Class: report 2005/09/16 v1.4f Standard LaTeX document class
(C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo))
(C:\Program Files\MiKTeX 2.7\tex\latex\geometry\geometry.sty
(C:\Program Files\MiKTeX 2.7\tex\latex\graphics\keyval.sty)
(C:\Program Files\MiKTeX 2.7\tex\latex\geometry\geometry.cfg))
No file file311f289a.aux.
[1] (file311f289a.aux) )
Output written on file311f289a.dvi (1 page, 372 bytes).
Transcript written on file311f289a.log.

At this point, I have to press ESC after a few minutes to regain the 
console, and no .dvi (yap) window appears.
If I go to the temp directory, C:/WINDOWS/TEMP/Rtmpz0QkT8/, the .dvi 
file is there and double-click

launches yap.

  optionsCmds(xdvi)
[1] yap

Reading the code of print.latex - show.latex - show.dvi, I tried 
executing  system() directly, in the forms


 system(paste(yap, C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi), 
intern=TRUE)


 system(paste(yap, C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi))

However, both of these result in the same behavior -- R console hangs 
until I press ESC.




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@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.


Re: [R] latex() hangs R console

2010-12-07 Thread RICHARD M. HEIBERGER
Michael,

The easiest workaround is to assign the result of the latex() command.

myfilename - latex(x)
print.default(myfilename)


It looks to me like the insides of the dvi.latex function aren't quite right
for Windows.

Rich

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] latex() hangs R console

2010-12-07 Thread Dennis Murphy
Hi:

I've experienced the same behavior as Dr. Friendly when trying to use
latex() in an Sweave code chunk (with results = tex in the chunk header) on
a Win7 system with 64-bit R (everything up to date). Is the answer the same
in that case?

TIA for your assistance,
Dennis

On Tue, Dec 7, 2010 at 9:52 AM, RICHARD M. HEIBERGER r...@temple.edu wrote:

 Michael,

 The easiest workaround is to assign the result of the latex() command.

 myfilename - latex(x)
 print.default(myfilename)


 It looks to me like the insides of the dvi.latex function aren't quite
 right
 for Windows.

 Rich

[[alternative HTML version deleted]]

 __
 R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] latex() hangs R console

2010-12-07 Thread Yihui Xie
I guess I know the answer but I am not completely clear about the
reason; print.latex() calls show.dvi() to open the DVI file using
system(), and under Windows it is usually better using shell() instead
of system(). The help page says shell() is a friendly wrapper of
system() under Windows, and this works:

shell(paste(yap, C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi))

So if might help to add an additional line for Windows:

if (.Platform$OS.type == 'windows') system = shell

 show.dvi
function (object, width = 5.5, height = 7)
{
viewer - optionsCmds(xdvi)
cmd - if (viewer == yap) {
paste(viewer, object$file)
}
else if (viewer == kdvi) {
paste(viewer, object$file)
}
else if (viewer == xdvi) {
paste(viewer,  -paper , width, x, height, in -s 0 ,
object$file, sep = )
}
else {
paste(viewer, object$file)
}
if (.Platform$OS.type == 'windows') system = shell
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment: namespace:Hmisc


Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Tue, Dec 7, 2010 at 8:05 PM, Dennis Murphy djmu...@gmail.com wrote:
 Hi:

 I've experienced the same behavior as Dr. Friendly when trying to use
 latex() in an Sweave code chunk (with results = tex in the chunk header) on
 a Win7 system with 64-bit R (everything up to date). Is the answer the same
 in that case?

 TIA for your assistance,
 Dennis

 On Tue, Dec 7, 2010 at 9:52 AM, RICHARD M. HEIBERGER r...@temple.edu wrote:

 Michael,

 The easiest workaround is to assign the result of the latex() command.

 myfilename - latex(x)
 print.default(myfilename)


 It looks to me like the insides of the dvi.latex function aren't quite
 right
 for Windows.

 Rich

        [[alternative HTML version deleted]]

 __
 R-help@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.


        [[alternative HTML version deleted]]

 __
 R-help@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@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] Latex and r

2010-06-16 Thread moleps
Dear R´ers 

I´m trying to get a summary table  using latex and summary in the rms package 
to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I have the mactex 
2009 distribution installed. Any obvious things I´m missing?

//M

 

options(digits=3)
set.seed(173)
sex - factor(sample(c(m,f), 500, rep=TRUE))
age - rnorm(500, 50, 5)
treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)

latex(f)

results in the following:


This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
entering extended mode

(/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex
LaTeX2e 2009/09/24
Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg))
No file file587f83cb.aux.
*geometry auto-detecting driver*
*geometry detected driver: dvips*

Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23
 [] 
[1] (./file587f83cb.aux)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 )
(see the transcript file for additional information)
Output written on file587f83cb.dvi (1 page, 1620 bytes).
Transcript written on file587f83cb.log.
sh: xdvi: command not found

__
R-help@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.


Re: [R] Latex and r

2010-06-16 Thread Erik Iverson



moleps wrote:

Dear R´ers

I´m trying to get a summary table  using latex and summary in the rms
package to no avail. I´m running R 2.10.1, Mac OS X snow leopard and
I have the mactex 2009 distribution installed. Any obvious things I´m
missing?




file587f83cb.log. sh: xdvi: command not found


You apparently don't have xdvi installed, which is used to view the 
resulting document. How you get that installed on your OS, I don't know. 
Depending on what you're doing, you might want to use the file 
argument of latex function to output a latex file, and then do further 
processing.  Also, assigning the latex function call to a variable, x - 
latex(...) will suppress printing of the object, which is ultimately 
what is trying to use xdvi.


__
R-help@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.


Re: [R] Latex and r

2010-06-16 Thread Erik Iverson



moleps wrote:

xdvi is installed in the same location as yours. I even did a
reinstallment of mactex. Still doesnt work. But since I´m now
convinced its related to my latex distribution I´ll take the problem
elsewhere..


And the directory that xdvi is located in is in your path?

__
R-help@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.


Re: [R] Latex and r

2010-06-16 Thread Kevin E. Thorpe

moleps wrote:
Dear R´ers 


I´m trying to get a summary table  using latex and summary in the rms package 
to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I have the mactex 
2009 distribution installed. Any obvious things I´m missing?

//M

 


options(digits=3)
set.seed(173)
sex - factor(sample(c(m,f), 500, rep=TRUE))
age - rnorm(500, 50, 5)
treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)

latex(f)

results in the following:


This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
entering extended mode

(/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex
LaTeX2e 2009/09/24
Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg))
No file file587f83cb.aux.
*geometry auto-detecting driver*
*geometry detected driver: dvips*

Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23
 [] 
[1] (./file587f83cb.aux)


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 )
(see the transcript file for additional information)
Output written on file587f83cb.dvi (1 page, 1620 bytes).
Transcript written on file587f83cb.log.
sh: xdvi: command not found



I believe there is something in the latex help page in the rms package 
that talks about preview difficulties on MAC.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@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.


Re: [R] Latex and r

2010-06-16 Thread Georg Otto
moleps mole...@gmail.com writes:

Apparently you don't have xdvi installed on your system.

HTH

Georg

 Dear R´ers 

 I´m trying to get a summary table  using latex and summary in the rms package 
 to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I have the 
 mactex 2009 distribution installed. Any obvious things I´m missing?

 //M

  

 options(digits=3)
 set.seed(173)
 sex - factor(sample(c(m,f), 500, rep=TRUE))
 age - rnorm(500, 50, 5)
 treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
 f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)

 latex(f)

 results in the following:


 This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
 entering extended mode

 (/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex
 LaTeX2e 2009/09/24
 Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, 
 noh
 yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, 
 ar
 abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, 
 dutc
 h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, 
 mono
 greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, 
 ku
 rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, 
 po
 lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, 
 span
 ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
 (/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls
 Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
 (/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo))
 (/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty
 (/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
 (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
 (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
 (/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg))
 No file file587f83cb.aux.
 *geometry auto-detecting driver*
 *geometry detected driver: dvips*

 Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23
  [] 
 [1] (./file587f83cb.aux)

 LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

  )
 (see the transcript file for additional information)
 Output written on file587f83cb.dvi (1 page, 1620 bytes).
 Transcript written on file587f83cb.log.
 sh: xdvi: command not found

__
R-help@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.


Re: [R] Latex and r

2010-06-16 Thread moleps
xdvi is installed in the same location as yours. I even did a reinstallment of 
mactex. Still doesnt work. But since I´m now convinced its related to my latex 
distribution I´ll take the problem elsewhere..

Regards,

//M



On 16. juni 2010, at 17.19, Prof Brian Ripley wrote:

 On Wed, 16 Jun 2010, Erik Iverson wrote:
 
 
 
 moleps wrote:
 Dear R´ers
 I´m trying to get a summary table  using latex and summary in the rms
 package to no avail. I´m running R 2.10.1, Mac OS X snow leopard and
 I have the mactex 2009 distribution installed. Any obvious things I´m
 missing?
 
 file587f83cb.log. sh: xdvi: command not found
 
 You apparently don't have xdvi installed, which is used to view the resulting
 
 xdvi is part of MacTeX 2009.  So the latter may be installed, but it is not 
 in the path or incomplete or   I have
 
 tystie% which xdvi
 /usr/texbin/xdvi
 
 
 document. How you get that installed on your OS, I don't know. Depending on 
 what you're doing, you might want to use the file argument of latex 
 function to output a latex file, and then do further processing.  Also, 
 assigning the latex function call to a variable, x - latex(...) will 
 suppress printing of the object, which is ultimately what is trying to use 
 xdvi.
 
 __
 R-help@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.
 
 
 -- 
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] Latex and r (using summary from RMS)

2010-06-16 Thread moleps
Dear all,
After spending all day and most of the night on this I did a new R-installation 
and it works. The question now is - upon running this code (from the Hmisc 
library-latex function) I believe the call to summary.formula is allright, but 
the latex command results in a totally different table where all the numbers 
and test columns are wrong are wrong. Is this still a matter for the 
installation or is there something in the latex syntax I havent grasped?

//M



library(Hmisc)

options(digits=3)
set.seed(173)
sex - factor(sample(c(m,f), 500, rep=TRUE))
age - rnorm(500, 50, 5)
treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
symp - c('Headache','Stomach Ache','Hangnail',
  'Muscle Ache','Depressed')
symptom1 - sample(symp, 500,TRUE)
symptom2 - sample(symp, 500,TRUE)
symptom3 - sample(symp, 500,TRUE)
Symptoms - mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms')
table (Symptoms)
table(symptom1,symptom2)
f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)
g - summary(treatment ~ age + sex + symptom1, method=reverse, test=TRUE)

latex(g)

Produces nice tables-but the numbers are all wrong as you can see below from 
the latex file...

 latex(g,file=)
% latex.default(cstats, title = title, caption = caption, rowlabel = rowlabel,  
col.just = col.just, numeric.dollar = FALSE, insert.bottom = legend,  
rowname = lab, dcolumn = dcolumn, extracolheads = extracolheads,  
extracolsize = Nsize, ...) 
%
\begin{table}[!tbp]
 \caption{Descriptive Statistics by treatment\label{g}} 
 \begin{center}
 \begin{tabular}{lccc}\hline\hline
\multicolumn{1}{l}{}\multicolumn{1}{c}{Drug}\multicolumn{1}{c}{Placebo}\multicolumn{1}{c}{Test
 Statistic}\tabularnewline

\multicolumn{1}{c}{{\scriptsize $N=263$}}\multicolumn{1}{c}{{\scriptsize 
$N=237$}}\tabularnewline
\hline
age114\tabularnewline
sex~:~m672\tabularnewline
symptom1~:~Depressed433\tabularnewline
Hangnail561\tabularnewline
Headache421\tabularnewline
Muscle~Ache351\tabularnewline
Stomach~Ache241\tabularnewline
\hline
\end{tabular}

\end{center}

\noindent {\scriptsize $a$\ }{$b$\ }{\scriptsize $c$\ } represent the lower 
quartile $a$, the median $b$, and the upper quartile $c$\ for continuous 
variables.\\Numbers after percents are frequencies.\\\indent Tests 
used:\\\textsuperscript{\normalfont 1}Wilcoxon test; 
\textsuperscript{\normalfont 2}Pearson test
\end{table}


Then I did another example from Harrell´s statistical tables and plots 

rm(list=ls())



library(Hmisc)
getHdata(prostate)
# Variables in prostate had units in ( ) inside variable labels. Move
# these units of measurements to separate units attributes
# wt is an exception. It has ( ) in its label but this does not denote units
# Also make hg have a legal R plotmath expression
prostate-upData(prostate, moveUnits=TRUE,units=c(wt=, 
hg=g/100*ml),labels=c(wt=Weight Index = wt(kg)-ht(cm)+200))

attach(prostate)
stage- factor(stage, 3:4, c(Stage 3,Stage 4))
s6-summary(stage~rx+age+wt+pf+hx+sbp+dbp+ekg+hg+sz+sg+ap+bm,method=reverse, 
overall=TRUE, test=TRUE)
options(digits=2)
w-latex(s6, size=smaller[3], outer.size=smaller, 
Nsize=smaller,long=TRUE, prmsd=TRUE, msdsize=smaller,middle.bold=TRUE, 
ctable=TRUE)


This refused to run ( as long as the ctable=T was included), but without it 

latex (s6)

I do get a nicely formated table, but again the numbers are all wrong... Also 

latex(s6, long=TRUE, prmsd=TRUE, msdsize=smaller,middle.bold=TRUE)

makes no difference from latex(s6) alone with regards to formatting...

Quite frustrating-Any suggestions??


//M






On 16. juni 2010, at 20.10, Kevin E. Thorpe wrote:

 moleps wrote:
 Dear R´ers I´m trying to get a summary table  using latex and summary in the 
 rms package to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I 
 have the mactex 2009 distribution installed. Any obvious things I´m missing?
 //M
 options(digits=3)
 set.seed(173)
 sex - factor(sample(c(m,f), 500, rep=TRUE))
 age - rnorm(500, 50, 5)
 treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
 f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)
 latex(f)
 results in the following:
 This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
 entering extended mode
 (/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex
 LaTeX2e 2009/09/24
 Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, 
 noh
 yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, 
 ar
 abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, 
 dutc
 h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, 
 mono
 greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, 
 ku
 rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, 
 po
 lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, 
 span
 ish, swedish, turkish, ukenglish, ukrainian, 

Re: [R] LaTeX and R-scripts/-results

2008-11-29 Thread Oliver Bandel
Hello Thomas (and all),


Zitat von Thomas Petzoldt [EMAIL PROTECTED]:

 Oliver Bandel wrote:
  Hello,
 
  at some places I read about good interaction of
  LaTeX and R.
 
  Can you give me a starting point, where I can find
  information about it?
 
  Are there special LaTeX-packages for the support,
  or does R have packages for support of LaTeX?
  Or will an external Code-Generator be used?
 
  TIA,
 Oliver


 Hi Oliver,

 you are right, LaTeX and R are perfect companions. Look for
 Sweave(*).
 You find an introduction of Fritz Leisch in R-News 2002, Vol 2/3:

 http://cran.r-project.org/doc/Rnews/Rnews_2002-3.pdf
[...]

OK, really wonderful tool!

This is something, I'm looking for since many years...
... maybe about a decade

... R as graphical pre-processor and data-analyser for LaTeX,
and LaTeX as a tool to write papers with analysed data imported into the
papers.

This noweb-based approach (literate programming is so wunderful)
is so much better than the many workarounds with so many other
tools. When I remember -- for example -- metapost and the problem of not
being able to name the outputs arbitrarily (using numbers for the
figures is the only possibility), and hand made inserting the results
with \includegraphics,  this is so much better!

Maybe noweb can also be used to insert not only R-stuff but also
creations from metapost, dia, dot (graphviz) and other tools into a
LaTeX-document.

This is the right way to make documents and research clean and
handy. :)


Ciao,
   Oliver

__
R-help@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.


Re: [R] LaTeX and R-scripts/-results

2008-11-26 Thread Thomas Petzoldt

Oliver Bandel wrote:

Hello,

at some places I read about good interaction of
LaTeX and R.

Can you give me a starting point, where I can find
information about it?

Are there special LaTeX-packages for the support,
or does R have packages for support of LaTeX?
Or will an external Code-Generator be used?

TIA,
   Oliver



Hi Oliver,

you are right, LaTeX and R are perfect companions. Look for Sweave(*). 
You find an introduction of Fritz Leisch in R-News 2002, Vol 2/3:


http://cran.r-project.org/doc/Rnews/Rnews_2002-3.pdf

and an entire homepage about it:

http://www.statistik.lmu.de/~leisch/Sweave/

HTH Thomas P.

(*) Many thanks to Friedrich Leisch for this great peace of software!

__
R-help@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.


Re: [R] LaTeX and R-scripts/-results

2008-11-26 Thread Philipp Pagel
On Wed, Nov 26, 2008 at 08:50:33AM +0100, Oliver Bandel wrote:
 at some places I read about good interaction of
 LaTeX and R.
 
 Can you give me a starting point, where I can find
 information about it?

Have a look at these:

Sweave()
xtable()(xtable)
latex() (Hmisc)

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@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] LaTeX and R-scripts/-results

2008-11-25 Thread Oliver Bandel
Hello,

at some places I read about good interaction of
LaTeX and R.

Can you give me a starting point, where I can find
information about it?

Are there special LaTeX-packages for the support,
or does R have packages for support of LaTeX?
Or will an external Code-Generator be used?

TIA,
   Oliver

__
R-help@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] LaTeX in R

2008-03-07 Thread Mario Maiworm
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?
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@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.


Re: [R] LaTeX in R

2008-03-07 Thread Uwe Ligges


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


Re: [R] LaTeX in R

2008-03-07 Thread Mario Maiworm
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?
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:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 15:27
 An: Mario Maiworm
 Cc: r-help@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@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@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.


Re: [R] LaTeX in R

2008-03-07 Thread Uwe Ligges
You might want to read
  Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation 
in Plots. R News 2 (3), 32-34.
with an example at the end that meets your requirements:

(please note that I removed those ugly ;


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)
legend1 - substitute(sigma == myS, list(myS = mySigma[1]))
legend2 - substitute(sigma == myS, list(myS = mySigma[2]))
legend(x = topright, lty = c(1,2),
legend = do.call(expression, list(legend1, legend2)))


Uwe Ligges



Mario Maiworm wrote:
 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:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 16:30
 An: Mario Maiworm
 Cc: r-help@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:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 15:27
 An: Mario Maiworm
 Cc: r-help@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@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@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.


Re: [R] LaTeX in R

2008-03-07 Thread Sundar Dorai-Raj
Or my personal favorite if the length of mySigma is variable:

mySigma - 2:3
plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l')
lines(dnorm(1:10,sd = mySigma[2]),lty = 2)
leg - as.expression(lapply(mySigma, function(x) bquote(sigma == .(x
legend(x = topright, lty = c(1,2),legend = leg)

Thanks,

--sundar

Uwe Ligges said the following on 3/7/2008 8:15 AM:
 You might want to read
   Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation 
 in Plots. R News 2 (3), 32-34.
 with an example at the end that meets your requirements:
 
 (please note that I removed those ugly ;
 
 
 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)
 legend1 - substitute(sigma == myS, list(myS = mySigma[1]))
 legend2 - substitute(sigma == myS, list(myS = mySigma[2]))
 legend(x = topright, lty = c(1,2),
 legend = do.call(expression, list(legend1, legend2)))
 
 
 Uwe Ligges
 
 
 
 Mario Maiworm wrote:
 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:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 16:30
 An: Mario Maiworm
 Cc: r-help@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:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 15:27
 An: Mario Maiworm
 Cc: r-help@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@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@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@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.


Re: [R] LaTeX in R

2008-03-07 Thread Mario Maiworm

I finally got everything plotted as I had planned. So, thank you again.
Sundars suggestion looks more flexible when it comes to large numbers of
categories (i.e. sigmas). In the plot I will be using, there are 3 sigmas...
I am keen to learn about that bquote and substitute stuff. I will definitely
take a look at your newsletter contribution, uwe.
The ';'s were intended to ease the mail2console copy-and-paste, as some mail
programs take control of your linebreaks.
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: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED]
 Gesendet: Freitag, 7. März 2008 17:22
 An: Uwe Ligges
 Cc: Mario Maiworm; r-help@r-project.org
 Betreff: Re: [R] LaTeX in R
 
 Or my personal favorite if the length of mySigma is variable:
 
 mySigma - 2:3
 plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l')
 lines(dnorm(1:10,sd = mySigma[2]),lty = 2)
 leg - as.expression(lapply(mySigma, function(x) bquote(sigma == .(x
 legend(x = topright, lty = c(1,2),legend = leg)
 
 Thanks,
 
 --sundar
 
 Uwe Ligges said the following on 3/7/2008 8:15 AM:
  You might want to read
Ligges, U. (2002): R Help Desk: Automation of Mathematical
 Annotation
  in Plots. R News 2 (3), 32-34.
  with an example at the end that meets your requirements:
 
  (please note that I removed those ugly ;
 
 
  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)
  legend1 - substitute(sigma == myS, list(myS = mySigma[1]))
  legend2 - substitute(sigma == myS, list(myS = mySigma[2]))
  legend(x = topright, lty = c(1,2),
  legend = do.call(expression, list(legend1, legend2)))
 
 
  Uwe Ligges
 
 
 
  Mario Maiworm wrote:
  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:[EMAIL PROTECTED]
  Gesendet: Freitag, 7. März 2008 16:30
  An: Mario Maiworm
  Cc: r-help@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:[EMAIL PROTECTED]
  Gesendet: Freitag, 7. März 2008 15:27
  An: Mario Maiworm
  Cc: r-help@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