R:写入数据库

时间:2019-03-19 11:46:26

标签: r dataframe

我使用以下语句将行名转换为列

library(tidyverse)
names(res) <- names(dt)[]
final<- imap(res, ~ .x %>% 
       as.data.frame %>% 
       select(!! .y := `Point Forecast`) %>% 
       rownames_to_column("Month_year")) %>% 
  reduce(inner_join, by = "Month_year") 

当我尝试将输出写入数据库时​​,

dbWriteTable(mycon, value = final , Database= 'mydb' ,name = "Rpredict", append = TRUE )

我收到如下错误:

Error in result_insert_dataframe(rs@ptr, values) : 
  nanodbc/nanodbc.cpp:1587: 42S22: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Month_year'

我该如何解决?

0 个答案:

没有答案