[R] "\r" with RSQLite

David James dj at research.bell-labs.com
Thu Mar 16 15:51:31 CET 2006


That is a bug, namely, the default end of line on the windows version 
should be "\r\n" instead of "\n".  The workaround is to specify 
eol="\r\n" in dbWriteTable(), e.g.,

   dbWriteTable(con, "DF", df, eol = "\r\n")
   dbReadTable(con, "DF")

Hope this helps,

--
David

PS The object .Platform includes path.sep and file.sep but not
end of line separator (as of 2.2.0) -- would it make sense to
also include eol.sep?

Mikkel Grum wrote:
> What am I doing wrong, or is the \r that I'm getting
> in the example below a bug?
> 
> > a <- (1:10)
> > b <- (LETTERS[1:10])
> > df <- as.data.frame(cbind(a, b))
> > 
> > df
>     a b
> 1   1 A
> 2   2 B
> 3   3 C
> 4   4 D
> 5   5 E
> 6   6 F
> 7   7 G
> 8   8 H
> 9   9 I
> 10 10 J
> > library(RSQLite)
> > drv <- dbDriver("SQLite")
> > con <- dbConnect(drv, dbname = "Test")
> >     dbWriteTable(con, "DF", df, row.names = FALSE,
> overwrite = TRUE)
> [1] TRUE
> >     df2 <- dbGetQuery(con, "SELECT DISTINCT * FROM
> DF")
> > dbDisconnect(con)
> [1] TRUE
> > df2
>     a   b
> 1   1 A\r
> 2   2 B\r
> 3   3 C\r
> 4   4 D\r
> 5   5 E\r
> 6   6 F\r
> 7   7 G\r
> 8   8 H\r
> 9   9 I\r
> 10 10 J\r
> 
> > sessionInfo()
> R version 2.2.1, 2005-12-20, i386-pc-mingw32 
> 
> attached base packages:
> [1] "methods"   "stats"     "graphics"  "grDevices"
> "utils"     "datasets" 
> [7] "base"     
> 
> other attached packages:
>  RSQLite      DBI 
>  "0.4-1" "0.1-10" 
> 
> 
> Mikkel Grum
> Genetic Diversity
> International Plant Genetic Resources Institute
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com




More information about the R-help mailing list