简体   繁体   English

R数据类型到MonetDB数据类型

[英]R Data Types to MonetDB Data Types

I am trying to insert a data frame into MonetDB using DBI::dbWriteTable() with the MonetDBLite driver and am having to adjust column types in both the MonetDB table and the R data frame. 我正在尝试使用带有MonetDBLite驱动程序的DBI::dbWriteTable()将数据帧插入MonetDB,并且必须调整MonetDB表和R数据帧中的列类型。

I am wondering if there is a mapping of data types from R to MonetDB. 我想知道是否存在从R到MonetDB的数据类型映射。 For instance, I know (or assume, rather) a character vector in R should map to a MonetDB column of CHAR(n), CHARACTER(n), VARCHAR(n), CHARACTER VARYING(n), TEXT, CLOB, CHARACTER LARGE OBJECT , or STRING and back. 例如,我知道(或假设为)R中的character向量应映射到CHAR(n), CHARACTER(n), VARCHAR(n), CHARACTER VARYING(n), TEXT, CLOB, CHARACTER LARGE OBJECT的MonetDB列CHAR(n), CHARACTER(n), VARCHAR(n), CHARACTER VARYING(n), TEXT, CLOB, CHARACTER LARGE OBJECTSTRING然后返回。

Is there any official documentation on this? 是否有任何官方文件? Google isn't turning anything up. Google没有任何进展。

There is a DBI function, dbDataType , that determines the database type for a R object. 有一个DBI函数dbDataType ,它确定R对象的数据库类型。 The MonetDBLite driver implements this function. MonetDBLite驱动程序实现此功能。 For example, 例如,

> library("DBI")
> con <- dbConnect(MonetDBLite::MonetDBLite())
> dbDataType(con, "asdf")
[1] "STRING"
> dbDataType(con, 1L)
[1] "INTEGER"
> dbDataType(con, 1)
[1] "DOUBLE PRECISION"

In case you are interested in the reverse, the R type that is created from a database type, there is also a (private) function in the MonetDBLite driver that does this. 如果您对相反的情况(从数据库类型创建的R类型)感兴趣,则MonetDBLite驱动程序中还有一个(专用)函数可以执行此操作。

> MonetDBLite:::monetdbRtype("BOOLEAN")
  BOOLEAN 
"logical" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM