Hello. I am posting this on behalf of a student in my class. I have been introducing them to R. I suspect that the problem I need help with is not so much an R issue, but a MAC config issue, but I don't have enough MAC experience to know what to do. Anyway, on to the problem. We are using Frank Harrell's Hmisc and Design packages. This student also wishes to use the latex formatting facilities provided in those packages so she has installed LaTeX. When she does something like latex(describe(dataframe)), the latex file is produced, the dvi file is successfully written but then the error "sh: line 1: xdvi: command not found" appears. I started a terminal and a "which xdvi" returned the path where it found xdvi. So, it appears that xdvi is in the PATH. My apologies, I forgot to get her sessionInfo() but I think she is running R 2.6.? -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.6057
I don't use Mac but a workaround to this type of problem was discussed just recently here: https://stat.ethz.ch/pipermail/r-help/2008-January/151524.html On Jan 23, 2008 9:22 AM, Kevin E. Thorpe <kevin.thorpe at utoronto.ca> wrote:> Hello. > > I am posting this on behalf of a student in my class. I have been > introducing them to R. > > I suspect that the problem I need help with is not so much an R > issue, but a MAC config issue, but I don't have enough MAC > experience to know what to do. > > Anyway, on to the problem. We are using Frank Harrell's Hmisc > and Design packages. This student also wishes to use the latex > formatting facilities provided in those packages so she has installed > LaTeX. > > When she does something like latex(describe(dataframe)), the latex > file is produced, the dvi file is successfully written but then > the error "sh: line 1: xdvi: command not found" appears. > > I started a terminal and a "which xdvi" returned the path > where it found xdvi. So, it appears that xdvi is in the > PATH. > > My apologies, I forgot to get her sessionInfo() but I think > she is running R 2.6.? > > -- > Kevin E. Thorpe > Biostatistician/Trialist, Knowledge Translation Program > Assistant Professor, Department of Public Health Sciences > Faculty of Medicine, University of Toronto > email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.6057 > > ______________________________________________ > 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. >
. I also have an issue on the Mac getting latex(describe(iris)) to work. I get the .tex file but this error: > latex(describe(iris)) This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %&-line parsing enabled. entering extended mode (/var/folders/AJ/AJjttUSSFdSi1HiInJZyY++++TI/-Tmp-//RtmpY5vKOM/ file10d63af1.tex LaTeX2e <2005/12/01> Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish, french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish, turkish, ukenglish, ukrainian, loaded. (/usr/local/texlive/2007/texmf-dist/tex/latex/base/report.cls Document Class: report 2005/09/16 v1.4f Standard LaTeX document class (/usr/local/texlive/2007/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2007/texmf-dist/tex/latex/setspace/setspace.sty Package: `setspace' 6.7 <2000/12/01> ) (/usr/local/texlive/2007/texmf-dist/tex/latex/ltxmisc/relsize.sty) (/usr/local/texlive/2007/texmf-dist/tex/latex/geometry/geometry.sty (/usr/local/texlive/2007/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2007/texmf-dist/tex/xelatex/xetexconfig/ geometry.cfg)) No file file10d63af1.aux. [1] (./file10d63af1.aux) ) Output written on file10d63af1.dvi (1 page, 4264 bytes). Transcript written on file10d63af1.log. sh: xdvi: command not found For LaTeX installation I used MacTeX 2007 live, which places files in a way that will allow multiple TeX installations. I sometimes have problems with TeX from the command line, but not with TeXShop which is the GUI that comes with the bundle. Where TeX gets installed for the Mac is described here: http://www.tug.org/mactex/ and http://www.tug.org/mactex/whatgetsinstalledwhere.html Finally, in the .tex file created above, several % were not escaped (I had to do that manually), and the text style {\smaller } is not on my TeX installation. \footnotesize is. Also I had to guess at the some of the packages required to get the latex to compile (e.g., setspacing). But otherwise, pretty dang nifty. -Dave -- David C. Airey, Ph.D. Pharmacology Research Assistant Professor Center for Human Genetics Research Member Vanderbilt University Medical Center
Nobody seems to have asked whether the student is using R from the Mac GUI, or R at the unix-style command line prompt. I have R 2.6.1 installed on a Mac running OS 10.4.11. When I start R at the command prompt in a terminal emulator in the X windows environment, the example expression, latex(describe(dataframe)), succeeds. xdvi starts up and displays the preview. When I use the Mac GUI, xdvi does not start up. Both ways of starting R are using the same installation of R. When started by double-clicking on the icon that represents R, the unix path is not inherited. It's probably more accurate to say that PATH does not exist, because no unix shell has been started. There are other mechanisms for creating environment variables that R can obtain via Sys.getenv(). (Create a file named environment.plist, or something like that, but I don't remember the exact details.) Even if the R gui environment is set up so that the path to xdvi is available, it won't necessarily work, because xdvi requires that an X windows server and window manager be running. That's not normally the case for most Mac users (one assumes). On Mac OS 10.5.x those should start automatically when xdvi is started, but not on earlier versions of Mac OS. (As an aside, this is probably the answer to Frank's comment, "shame on Mac" (for not inheriting path) -- if one wants the Mac to act like a linux box, then one must do one's work from within a unix shell. That's done either from the Terminal application, or other terminal emulator.) The experts on this issue are best reached through R-sig-mac. A search of the archives will probably reveal how to define unix stye environment variables such as PATH, that the Mac R gui can use. The Mac-related pages at CRAN may also have this information. -Don At 9:22 AM -0500 1/23/08, Kevin E. Thorpe wrote:>Hello. > >I am posting this on behalf of a student in my class. I have been >introducing them to R. > >I suspect that the problem I need help with is not so much an R >issue, but a MAC config issue, but I don't have enough MAC >experience to know what to do. > >Anyway, on to the problem. We are using Frank Harrell's Hmisc >and Design packages. This student also wishes to use the latex >formatting facilities provided in those packages so she has installed >LaTeX. > >When she does something like latex(describe(dataframe)), the latex >file is produced, the dvi file is successfully written but then >the error "sh: line 1: xdvi: command not found" appears. > >I started a terminal and a "which xdvi" returned the path >where it found xdvi. So, it appears that xdvi is in the >PATH. > >My apologies, I forgot to get her sessionInfo() but I think >she is running R 2.6.? > >-- >Kevin E. Thorpe >Biostatistician/Trialist, Knowledge Translation Program >Assistant Professor, Department of Public Health Sciences >Faculty of Medicine, University of Toronto >email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.6057 > >______________________________________________ >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.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062
On 24/01/2008, at 10:00 PM, Kevin E. Thorpe wrote:> > When she does something like latex(describe(dataframe)), the latex > file is produced, the dvi file is successfully written but then > the error "sh: line 1: xdvi: command not found" appears. > > I started a terminal and a "which xdvi" returned the path > where it found xdvi. So, it appears that xdvi is in the > PATH.Firstly if you have questions about R on MacOS you be much more likely to get a useful reply on r-sig-mac rather than this list. Secondly for the benefit of the non-Mac types here I will try to explain what is going on. On most UNIXen or Linux virtually all process are launched from a shell process. Hence they inherit the environment of a standard shell, and it makes sense to think of 'the' PATH or 'the' environment. MacOS works differently. Most processes are not launched from a shell. The only time you really have a shell involved is if you open the Terminal app. Then you get a Quartz window running a shell and any process you start from that shell will inherit the shell's environment variables. However, if you start the R GUI app from the Finder or Dock, there is no shell in the process hierarchy (use '/Applications/Utilities/ Activity Monitor' to view the process hierarchy) and the environment variables for the R app and anything it invokes are set up in the .plist files in the R Application bundle. Those environment variables are not going to include the Tex paths like /usr/texbin or / usr/local/tetex/bin etc.. Three ways to get over it: 1. Launch a command line R session from a Terminal shell. 2. Start the GUI app from a Terminal shell with 'open /Applications/ R.app' 3. Set the PATH in your R code Finally, the way to check your PATH in R is Sys.getenv("PATH"). Which for the R 2.6.1 GUI app on this PowerMac G5 gives "/usr/bin:/bin:/usr/ sbin:/sbin:/usr/local/bin" Hope this helps Bill Northcott
Kevin E. Thorpe
2008-Jan-25 16:43 UTC
[R] *SOLVED* latex{Hmisc} cannot find xdvi on MAC OS X
With thanks to all who responded, especially Charles Berry and Don MacQueen, my student has everything working. The final solution was: 1. Install X11 and X11SDK (or make sure they are installed). 2. There is a button for starting X11 within the R GUI. 3. Sys.setenv( PATH=paste(Sys.getenv("PATH"),"/usr/texbin",sep=":") ) After doing this, latex() worked as desired when R is started from the MAC Finder. She and I thank you. Kevin Kevin E. Thorpe wrote:> Hello. > > I am posting this on behalf of a student in my class. I have been > introducing them to R. > > I suspect that the problem I need help with is not so much an R > issue, but a MAC config issue, but I don't have enough MAC > experience to know what to do. > > Anyway, on to the problem. We are using Frank Harrell's Hmisc > and Design packages. This student also wishes to use the latex > formatting facilities provided in those packages so she has installed > LaTeX. > > When she does something like latex(describe(dataframe)), the latex > file is produced, the dvi file is successfully written but then > the error "sh: line 1: xdvi: command not found" appears. > > I started a terminal and a "which xdvi" returned the path > where it found xdvi. So, it appears that xdvi is in the > PATH. > > My apologies, I forgot to get her sessionInfo() but I think > she is running R 2.6.? >-- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.6057