[R] Unwanted carriage returns storing dataframes with dbWriteTable

Hansruedi Baetschmann habae at fgcz.ethz.ch
Mon Aug 11 14:01:37 CEST 2008


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>



More information about the R-help mailing list