[R] Export R output in Excel

Spencer Graves spencer.graves at effectivedefense.org
Thu Dec 29 14:15:13 CET 2016


       The "writeFindFn2xls" function in the sos package include 3 
different ways to write an Excel workbook, depending on which packages, 
etc., you have installed.  I wrote that, because I could not find one 
contributed package that as easy to install on every operating system.  
This writes an Excel workbook with 3 sheets. That may not be what you 
want, but it might provide other options.


Spencer Graves

On 2016-12-29 3:19 AM, Jim Lemon wrote:
> Hi Bryan,
> What functions like "htmlize" (prettyR) do is format the basic R
> output into HTML tables with the option of interspersed graphics.
> While I usually stop at the HTML stage, the output files can be
> imported into Word for those who cannot work out how to open them with
> an HTML browser. I just tried the example for "htmlize" and it imports
> into Libre Office Writer fine, but doesn't fit so well into Libre
> Office Calc, which does not bode well for an import into Excel. At
> best you will get formatted output, but you cannot play with the
> numbers as you would in a spreadsheet. Petr's suggestion, which I just
> read, is an alternative that may be more useful to you.
>
> Jim
>
>
> On Thu, Dec 29, 2016 at 2:58 PM, Bryan Mac <bryanmac.24 at gmail.com> wrote:
>> Hi Jim,
>>
>> Your assumption is correct. When running the analyses in R and want to export the output that appears in the console window to Excel(.csv) file.
>> I believe it is easier to do if the export it done to an Excel (.CSV) file.
>>
>> So is there a way to export the analyses in the console window to a .CSV file with the good formatting ?
>> I am looking to export the whole output if possible.
>>
>> I found this code, but it doesn’t cover the whole output of the console.
>>
>> write.csv(coef(summary(test)), file=“test.csv”)
>>
>> My whole output consists of descriptives and regressions.
>>
>> Best,
>>
>> Bryan Mac
>> bryanmac.24 at gmail.com
>>
>>
>>
>>> On Dec 28, 2016, at 6:33 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
>>>
>>> Hi Bryan,
>>> When I have to do something like this, I usually go through HTML
>>> output and import it into MS Word. I am not suggesting that this is
>>> the best thing to do, but it might get you out of trouble. I'm not
>>> sure whether importing HTML into Excel will work as well. I assume
>>> that you are running analyses in R and want to export the output that
>>> appears in the console window. If so, try producing HTML output with
>>> the prettyR or R2HTML packages and importing it. There are other ways
>>> to do this, but the learning curve is steep and you might not want to
>>> climb it right now.
>>>
>>> Jim
>>>
>>>
>>> On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac <bryanmac.24 at gmail.com> wrote:
>>>> Hi,
>>>>
>>>> How do I export results from R to Excel in a format-friendly way? For example, when I copy and paste my results into excel, the formatting is messed up.
>>>>
>>>> Thanks.
>>>>
>>>> Bryan Mac
>>>> bryanmac.24 at gmail.com
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> 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 at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list