Skip to content

A question about dbWriteTable command in R under MS Windows

3 messages · HU,ZHENGJUN, Christophe Dutang, Jeffrey Horner

#
Dear Sir/Madam,

  I wrote the following R code (see below) to store the data frame 
of "test.01" into the table of "ttest01" in my database which is 
located on a Linux machine. If the code was run under MS Windows 
XP, I have found that the values in the last column (i.e. column 
f5) in the table are all zeros instead of NULLs. If the same R 
code was run under Linux, however, everything is OK. The R version 
is 2.6.0 under both MS Windows XP and Linux.

  Does anyone know how to solve this problem under MS Windows XP?

  Thank you very much for the help and time in advance. Howard

********************************************************************************************
library(DBI)
library(RMySQL)
mysqldrv <- dbDriver("MySQL")
conn.2.database<- 
dbConnect('myHostName','myUserName','myPassword','myDatabaseName')
test.01=data.frame(f1=c("A","B","C"),f2=c(1,2,3),f3=c(NA,NA,NA),f4=c(NA,NA,NA),f5=c(NA,NA,NA))
dbWriteTable(conn.2.database, "ttest01", test.01, row.names=F, 
eol='\r\n')
dbDisconnect(conn.2.database)
#
Hi,

try with the latest version R, i.e. 2.8.1 and tell us which version of  
mysql and rmysql do you use.

Le 10 mars 09 ? 22:32, HU,ZHENGJUN a ?crit :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
Hi,

HU,ZHENGJUN wrote on 03/10/2009 04:32 PM:
I suggest you upgrade to the latest version of R and the latest version 
of RMySQL and run your test again. I doubt R 2.6.0 is the problem, but 
you haven't told us which version of RMySQL you are using. The latest 
version of RMySQL is 0.7-3, and a fix was made to dbWriteTable() in the 
0.7-2 version.

Best,

Jeff