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. Is this a bug, that sink does not capture the output of objects of class packageInfo? Best Wishes, spencer graves
On Sat, 24 Jul 2004, Spencer Graves wrote:> 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. > > Is this a bug, that sink does not capture the output of objects of > class packageInfo? >Not really. The output doesn't really appear on your screen, it appears on your pager. In your case the pager is the screen, so this isn't obvious. -thomas
On Sat, 24 Jul 2004 10:06:02 -0700, Spencer Graves <spencer.graves at pdf.com> wrote:> 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. > > Is this a bug, that sink does not capture the output of objects of >class packageInfo?I don't think so. The print method for that class calls other code to display it; it doesn't go through the regular "display to console" route. Instead, it writes the help page to a file, then calls file.show. It's possible that on some systems file.show would just dump the file to the console, but that's not what happens on Windows, for example. Duncan Murdoch
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.