[R] Exporting a dataframe from R to Excel

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Feb 25 14:24:25 CET 2008


Where did you get the idea to use sqlUpdate from?
sqlSave is how you write a database to a table.

I think it would be easier to use write.csv to write a .csv file and 
import that into Excel.  ODBC connections to Excel work much better for 
reading than for writing.  And there are other ways: see the relevant 
manual ('R Data Import/Export').

On Mon, 25 Feb 2008, Nadia Theron wrote:

> I am trying to export a dateframe created in R:
>
>
>
>> Duration_summary
>
>     V1      2.5 %   97.5 %       V4     2.5 %    97.5 %
>
> [1,]  1 0.46076018 1.128776 1.000000 0.5280828 0.9576338
>
> [2,]  0 0.00000000 0.000000 1.000000 0.1741793 1.2352705
>
> [3,]  1 0.46566719 1.313711 1.000000 0.7233312 1.4097987
>
> [4,]  1 0.38866371 2.453226 0.976024 0.6377314 1.3493957
>
> [5,]  1 0.08894066 1.036830 1.000000 0.5270633 1.0901834

Looks like a matrix to me: data frames must have row names.

>
>
> into a named are in Excel of the correct size, but I do not want to
> export the rownames as well. I've tried using RODBC sqlUpdate:
>
>
>
> sqlUpdate(channel=channel, dat=Duration_summary, index = NULL,verbose =
> FALSE, test = FALSE,nastring = NULL, fast = TRUE)
>
> Error in sqlUpdate(channel = channel, dat = Duration_summary, index =
> NULL,  :
>
>        cannot update 'Duration_summary' without unique column
>
> Please help...
>
>
> http://www.investec.com/EmailDisclaimer/emaildisclaimer.htm
>
> The disclaimer also provides our corporate information and names of our directors as required by law.
>
> The disclaimer is deemed to form part of this message in terms of Section 11 of the Electronic Communications and Transactions Act 25 of 2002.
> If you cannot access the disclaimer, please obtain a copy thereof from us by sending an email to: disclaimer at investec.co.za
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list