Re: [R] Formatting summary() output to a file

2018-07-27 Thread MacQueen, Don via R-help
Hmmm. I do get output in the file with the first example, and the second example is too complicated for me. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 On 7/27/18, 9:56 AM, "R-help on behalf of Rich

Re: [R] Formatting summary() output to a file

2018-07-27 Thread Rich Shepard
On Fri, 27 Jul 2018, William Dunlap wrote: I often use capture.output to slightly reformat printout output. E.g, to indent str's output to make it easier to read debugging printouts: debug_print <- function(x, name=substitute(x), indent=4) { cat(sep="\n", name, paste0(strrep(" ", indent), cap

Re: [R] Formatting summary() output to a file

2018-07-27 Thread William Dunlap via R-help
I often use capture.output to slightly reformat printout output. E.g, to indent str's output to make it easier to read debugging printouts: debug_print <- function(x, name=substitute(x), indent=4) { cat(sep="\n", name, paste0(strrep(" ", indent), capture.output(str(x } Used as in > myData <

Re: [R] Formatting summary() output to a file

2018-07-27 Thread Rich Shepard
On Fri, 27 Jul 2018, MacQueen, Don wrote: Given your description, I would start with sink('wysumallyrs.txt') print( summary(wyallyrs) ) sink() and see if that doesn't meet your needs. Don, I started with sink() trying to follow

Re: [R] Formatting summary() output to a file

2018-07-27 Thread MacQueen, Don via R-help
Given your description, I would start with sink('wysumallyrs.txt') print( summary(wyallyrs) ) sink() and see if that doesn't meet your needs. Some of the basic principles: (1) Whenever you type the name of an R object at the R prompt, it is as if R wraps whatever you typed inside print(). Here

Re: [R] Formatting summary() output to a file

2018-07-27 Thread Rich Shepard
On Fri, 27 Jul 2018, Bert Gunter wrote: print.summaryDefault ## at the prompt. It's in base R, so no package:: prefix needed will give you the code used for formatting. You can then do the same. Bert, Thank you. Rich __ R-help@r-project.org mai

Re: [R] Formatting summary() output to a file

2018-07-27 Thread Bert Gunter
Not quite sure what you mean here. R is open source, so > print.summaryDefault ## at the prompt. It's in base R, so no package:: prefix needed will give you the code used for formatting. You can then do the same. Cheers, Bert Bert Gunter "The trouble with having an open mind is that pe

Re: [R] Formatting summary() output to a file

2018-07-27 Thread William Dunlap via R-help
Try cat(sep="\n", file=con, capture.output(summary(...))) capture.output(x) return character vector whose elements contain the lines of text that would have been printed by print(x). Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Jul 27, 2018 at 8:20 AM, Rich Shepard wrote: > I want

Re: [R] Formatting summary() output to a file

2018-07-27 Thread Rich Shepard
On Fri, 27 Jul 2018, William Dunlap wrote: Try cat(sep="\n", file=con, capture.output(summary(...))) capture.output(x) return character vector whose elements contain the lines of text that would have been printed by print(x). Bill, Thanks very much. I doubt my searches would have found ca

[R] Formatting summary() output to a file

2018-07-27 Thread Rich Shepard
I want to save the output of summary(df_name) to a disk file and my research found that the sink() function is what I want to use. The 'R Cookbook' provides a an alternative example using cat() to a connection. Here, con <- file("wysumallyrs.txt", "w") cat(summary(wyallyrs), file=con) close(con