[R] Unwanted carriage returns storing dataframes with dbWriteTable

Prof Brian Ripley
Mon, 11 Aug 2008 12:22:08 -0000

Which package is this?  (Clearly DBI, not mentioned, but which backend,
and what OS?  I was unaware that there was a DBI package that works with
(Microsoft) SQL Server.)

Please note the 'at a minimum' information the R posting guide asked you
for.

Such questions are perhaps best asked on R-sig-db, with the requested
information and a complete reproducible example.

On Mon, 11 Aug 2008, Hansruedi Baetschmann wrote:

> If I save a dataframe with a character-typed last column to a relational
> database with dbWriteTable, the  values in the last column of the resulting
> table in the database will have a '\r' (carriage return) appended.
If I read
> back the dataframe with dbReadTable the last column in the resulting
> dataframe has also '\r' appended (see protocol below). Setting or
unsetting
> sql-mode (in the SQL-Server Version 5.0) to or from
'NO_BACKSLASH_ESCAPE' has
> no effect on this behavour ? How can I avoid these unwanted
'\r'-tail ?
>
> Hansruedi
>> df1
> a c
> a 1 x
> b 2 y
> c 3 z
> d 4 t
>> dbWriteTable(con,"df1",df1,row.names=FALSE)
> [1] TRUE
>> df1=dbReadTable(con,"df1")
>> df1
> a   c
> 1 1 x\r
> 2 2 y\r
> 3 3 z\r
> 4 4 t\r
>>
>
> --
> Hansruedi Baetschmann
> dipl.math.ETH et lic.oec.HSG
> Mail     Weierweg 16
> CH-8725 Ernetschwil     Functional Genomics Center Zurich
> Winterthurerstrasse 190 / Y32H66
> CH-8057 Z?rich
> Phone     +41 79 235 46 49     +41 44 635 39 (64 | 24 | Fax 22)
> Email     habae at hispeed.ch     habae at fgcz.ethz.ch
> URL     homepage.hispeed.ch/bae <http://homepage.hispeed.ch/bae>
> www.fgcz.ethz.ch/people/hbaetschmann
> <http://www.fgcz.ethz.ch/people/hbaetschmann>
> Blog     blogs.ethz.ch/bae <http://blogs.ethz.ch/bae>
>
> ______________________________________________
> 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