[R] dbWriteTable with row.names=(TRUE | FALSE)
Hansruedi Baetschmann
habae at fgcz.uzh.ch
Fri Aug 8 21:04:24 CEST 2008
Hello
Saving a dataframe with dbWriteTable to a relational database with the
parameter row.names set to FALSE works fine, doing so the parameter set
to TRUE gives an error message "/Fehler in field.types$row.names : $
operator is invalid for atomic vectors/" (see the protocol below).
I work with R Ver.2.7.1
What am I doing wrong ?
Thanks
Hansruedi Baetschmann
dipl.math.ETH et.lic.oec.HSG
Functional Genomics Center Zurich
Winterthurerstrasse 190 / Y32H66
CH-8057 Zürich
### Begin ###
> library("RMySQL")
> con=dbConnect("MySQL",dbname="dataframes",user="root",
password="xxxxx",host="localhost" )
> dbGetInfo(con)
$host
[1] "localhost"
$user
[1] "root"
$dbname
[1] "dataframes"
$conType
[1] "localhost via TCP/IP"
$serverVersion
[1] "5.0.24-community-nt-log"
$protocolVersion
[1] 10
$threadId
[1] 111
$rsId
list()
> dbListTables(con)
character(0)
> df1=data.frame(a=c(1,2,3,4),b=c("a","b","c","d"))
> df1
a b
1 1 a
2 2 b
3 3 c
4 4 d
> dbWriteTable(con,"df1_without_rownames",df1,row.names=FALSE)
[1] TRUE
> dbListTables(con)
[1] "df1_without_rownames"
> dbWriteTable(con,"df1_with_rownames",df1,row.names=TRUE)
Fehler in field.types$row.names : $ operator is invalid for atomic vectors
> dbDisconnect(con)
[1] TRUE
>
### End ###
More information about the R-help
mailing list