[R] RSQLite problems

Roger D. Peng rpeng at jhsph.edu
Thu Oct 27 20:35:04 CEST 2005


I encountered this too, and my limited investigation (both on the web and in R) 
was unable to find a work around.

-roger

Na Li wrote:
> Hi, I'm experimenting with using (R)SQLite to do data management.  Here are
> two little problems that I've encountered:
> 
> 1. The presence of ',' in string values causes trouble since ',' is also the
>    delimiter used in the SQL statement. 
> 
> 2. A newline '\n' line attached to the last string value of each row. 
> 
> Some examples:
> 
> 
>>library (RSQLite)
> 
> Loading required package: DBI
> 
>>sqlite <- dbDriver ("SQLite")
>>db <- dbConnect (sqlite, dbname = "test.dbms")
>>data (barley)
>>dbWriteTable (db, "barley", barley, overwrite = TRUE)
> 
> [1] TRUE
> 
>>barley[1:3,]
> 
>      yield   variety year            site
> 1 27.00000 Manchuria 1931 University Farm
> 2 48.86667 Manchuria 1931          Waseca
> 3 27.43334 Manchuria 1931          Morris
> 
>>dbReadTable (db, "barley")[1:3,]
> 
>      yield   variety year__1              site
> 1 27.00000 Manchuria    1931 University Farm\n
> 2 48.86667 Manchuria    1931          Waseca\n
> 3 27.43334 Manchuria    1931          Morris\n
> 
> 
>>barley$site <- as.character (barley$site)
>>barley$site[1] <- "University, Farm"
>>dbWriteTable (db, "barley", barley, overwrite = TRUE)
> 
> Error in sqliteWriteTable(conn, name, value, ...) : 
> 	RS-DBI driver: (RS_sqlite_import: /tmp/RtmpgSNaLn/rsdbi6a5d128c line 1
> expected 5 columns of data but found 6)
> 
> I'm using RSQLite 0.4.0 with R 2.1.1 on Mac OS X.
> 
> Cheers,
> 
> Michael
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/




More information about the R-help mailing list