[R] export tables to Excel files

Erich Neuwirth erich.neuwirth at univie.ac.at
Thu Feb 25 12:25:40 CET 2010


OK, I think dirung the disuccion we mixed up the directions of transfer.
The example I sent was Excel -> R
For R -> Excel you need something like


RInterface.GetDataframe "dfname", Worksheets("wsname").Range("A1")

dfname, wsname and the cell refence ("A1")
have to be given for each dataframe you want to transfer.


You need to install RExcel to do this.

CRAN has a package RExcelInstaller
which does everything for you.



On 2/24/2010 4:35 PM, Tal Galili wrote:
> Hi Erich.
> I admit I haven't gotten all that is necessary to implement it.
> But thanks anyway :)
> 
> Tal
> 
> 
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com <mailto:Tal.Galili at gmail.com> |
>  972-52-7275845
> Read me: www.talgalili.com <http://www.talgalili.com> (Hebrew) |
> www.biostatistics.co.il <http://www.biostatistics.co.il> (Hebrew) |
> www.r-statistics.com <http://www.r-statistics.com> (English)
> ----------------------------------------------------------------------------------------------
> 
> 
> 
> 
> On Wed, Feb 24, 2010 at 12:55 PM, Erich Neuwirth
> <erich.neuwirth at univie.ac.at <mailto:erich.neuwirth at univie.ac.at>> wrote:
> 
>     This was a VBA program which from R put the dataframes into R.
>     Then in R you can do whatever you want.
> 
> 
>     On 2/24/2010 7:52 AM, Tal Galili wrote:
>     > (off mailing list)
>     > Thanks Erich for the example, only please note that I asked about the
>     > other way around (reading the excel into R)
>     >
>     > Either way - Thanks!
>     > Tal
>     >
>     >
>     >
>     > ----------------Contact
>     > Details:-------------------------------------------------------
>     > Contact me: Tal.Galili at gmail.com <mailto:Tal.Galili at gmail.com>
>     <mailto:Tal.Galili at gmail.com <mailto:Tal.Galili at gmail.com>> |
>     >  972-52-7275845
>     > Read me: www.talgalili.com <http://www.talgalili.com>
>     <http://www.talgalili.com> (Hebrew) |
>     > www.biostatistics.co.il <http://www.biostatistics.co.il>
>     <http://www.biostatistics.co.il> (Hebrew) |
>     > www.r-statistics.com <http://www.r-statistics.com>
>     <http://www.r-statistics.com> (English)
>     >
>     ----------------------------------------------------------------------------------------------
>     >
>     >
>     >
>     >
>     > On Wed, Feb 24, 2010 at 1:01 AM, Erich Neuwirth
>     > <erich.neuwirth at univie.ac.at <mailto:erich.neuwirth at univie.ac.at>
>     <mailto:erich.neuwirth at univie.ac.at
>     <mailto:erich.neuwirth at univie.ac.at>>> wrote:
>     >
>     >     In RExcel, you can write VBA macros to perform R-related function.
>     >     A cooked up example (not checked)
>     >
>     >     Sub TransferFrames()
>     >      MySheetNames = Array("Sheet1", "Sheet2", "Sheet3")
>     >      MyDFNames = Array("mydf1", "mydf2", "mydf3")
>     >      RInterface.StartRServer
>     >      For i = Lbound(MySheetNames) to UBound(MySheetNames)
>     >      RInterface.PutDataframe MyDFNames(i), _
>     >                  
>      Worksheets(MySheetNames(i)).Range("A1").CurrentRegion
>     >      Next i
>     >     End Sub
>     >
>     >
>     >     This will take the data in the rectangular nonempty range
>     >     anchored at cell A1 for the 3 names sheets and transfer them
>     >     to R as dataframes with the names given in MyDFNames
>     >
>     >
>     >     On 2/23/2010 10:46 PM, Tal Galili wrote:
>     >     > Hi Richard,
>     >     > Thanks for pointing this out.
>     >     >
>     >     > BTW - How would you use Rexcel to write several data frames into
>     >     several
>     >     > sheets in excel ?
>     >     >
>     >     > Thanks!
>     >     >
>     >     > Tal
>     >     >
>     >     >
>     >     >
>     >     > ----------------Contact
>     >     > Details:-------------------------------------------------------
>     >     > Contact me: Tal.Galili at gmail.com
>     <mailto:Tal.Galili at gmail.com> <mailto:Tal.Galili at gmail.com
>     <mailto:Tal.Galili at gmail.com>> |
>     >      972-52-7275845
>     >     > Read me: www.talgalili.com <http://www.talgalili.com>
>     <http://www.talgalili.com> (Hebrew) |
>     >     www.biostatistics.co.il <http://www.biostatistics.co.il>
>     <http://www.biostatistics.co.il> (Hebrew) |
>     >     > www.r-statistics.com <http://www.r-statistics.com>
>     <http://www.r-statistics.com> (English)
>     >     >
>     >    
>     ----------------------------------------------------------------------------------------------
>     >     >
>     >     >
>     >     >
>     >     >
>     >     > On Tue, Feb 23, 2010 at 5:04 PM, RICHARD M. HEIBERGER
>     >     <rmh at temple.edu <mailto:rmh at temple.edu> <mailto:rmh at temple.edu
>     <mailto:rmh at temple.edu>>>wrote:
>     >     >
>     >     >> Please consider RExcel, which allows complete integration of R
>     >     and Excel.
>     >     >> See http://rcom.univie.ac.at
>     >     >> for details and examples including a video.
>     >     >> RExcel works in both directions (R to Excel, Excel to R) with
>     >     >> Excel 2010, 2007, 2003, and 2002.
>     >     >>
>     >     >> Rich
>     >     >>
>     >     >>        [[alternative HTML version deleted]]
>     >     >>
>     >     >> ______________________________________________
>     >     >> R-help at r-project.org <mailto:R-help at r-project.org>
>     <mailto:R-help at r-project.org <mailto: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.
>     >     >>
>     >     >
>     >     >       [[alternative HTML version deleted]]
>     >     >
>     >     > ______________________________________________
>     >     > R-help at r-project.org <mailto:R-help at r-project.org>
>     <mailto:R-help at r-project.org <mailto: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.
>     >     >
>     >     >
>     >
>     >     --
>     >     Erich Neuwirth, University of Vienna
>     >     Faculty of Computer Science
>     >     Computer Supported Didactics Working Group
>     >     Visit our SunSITE at http://sunsite.univie.ac.at
>     >     Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
>     >
>     >     ______________________________________________
>     >     R-help at r-project.org <mailto:R-help at r-project.org>
>     <mailto:R-help at r-project.org <mailto: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.
>     >
>     >
> 
>     --
>     Erich Neuwirth, University of Vienna
>     Faculty of Computer Science
>     Computer Supported Didactics Working Group
>     Visit our SunSITE at http://sunsite.univie.ac.at
>     Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
> 
> 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459



More information about the R-help mailing list