[R] help(package)->sink()

Spencer Graves spencer.graves at pdf.com
Sun Jul 25 02:47:17 CEST 2004


      Thanks to Tom Lumley and Duncan Murdoch for explaining that this 
was a feature not a bug and to Gabor Grothendieck for providing several 
ways to get around the problem.  (Please excuse, Gabor:  I should have 
said I was using R 1.9.1 under Windows 2000.) 

      1.  I failed to make method 1 work, though I've done that kind of 
thing in the past, and I believe I could make it work if I had to. 
    
      2.  I found the DESCRIPTION and INDEX files.  Thanks much.  That 
not only answers this immediate question, it help me understand how R 
packages are structured, which will help me solve many related problems 
in the future. 

      3.  Before I sent the email, I tried dump("mclustInfo", 
"mclust.txt").  That worked, but I did not like the formatting.  I 
should have reported that in my email. 

      4.  A request for "packageInfo.print" returned "object ... not 
found".  A request for class(mclustInfo) confirmed that it was a 
packageInfo object, so I tried getMethod("print",  "packageInfo");   I 
got, 'No generic function defined for "print"'.  Then I tried, 
getMethod("show", "packageInfo");  I got, 'No method defined for 
function "show" and signature object = "packageInfo"'. 

      Anyway, I now have more than one method that works. 
      thanks again.  spencer graves

Gabor Grothendieck wrote:

>Spencer Graves <spencer.graves <at> pdf.com> writes:
>
>: 
>: I wanted to direct packageInfo to a file, so I could add comments, 
>: e.g., in MS Word.  The following command stored the desired information 
>: in an object: 
>: 
>:       mclustInfo <- help(package="mclust")
>: 
>:       Then "mclustInfo" displays it on my screen.  To direct it to a 
>: file, I tried the following: 
>: 
>:       sink("mclust.txt")
>:       mclustInfo
>:       sink()
>: 
>:       This sequence created an empty file "mclust.txt", while displaying 
>: mclustInfo on my screen.  After a few more failed attempts, I gave up 
>: trying to be clever and copied the text from the screen into Word. 
>
>In addition to your copy and paste solution:
>
>1. You could intercept the file.show output by redefining the pager:
>
>   a. create a one line file called mypager.bat in \ with this line:
>
>      type %1 > /mclust.txt
>
>   (with appropriate modifications if you are using UNIX).
>
>   b. In R issue these commands:
>
>      old <- options()
>      options(pager = "/mypager.bat")
>      help(package = "mclust")
>      options(old) # reset options back if finished
>
>2. Don't use R but go right to the DESCRIPTION and INDEX
>   files.  getwd("library/mclust") should show you where
>   to find them.
>
>3. If you don't care about the formatting:
>
>      sink("/mclust.txt")
>      writeLines(unlist(help(package="mclust")$info))
>      sink()
>
>4. You could modify packageInfo.print adding a file= argument.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list