Hello,

Using the RpgSQL package, there must be a way to get the row names into the
table automatically. In the example below, I'm trying to get rid of the
cbind line, yet have the row names of the data frame populate a column.

> bentest = matrix(1:4,2,2)
> dimnames(bentest) = list(c('ra','rb'),c('ca','cb'))
> bentest
   ca cb
ra  1  3
rb  2  4
> bentest = cbind(item_name=rownames(bentest),bentest)
> dbWriteTable(con, "r.bentest", bentest)
[1] TRUE
> dbGetQuery(con, "SELECT * FROM r.bentest")
  item_name ca cb
1        ra  1  3
2        rb  2  4


Thanks,
Ben

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to