简体   繁体   English

将R randomForest对象保存到SQL数据库

[英]Save R randomForest object to SQL database

Is there a way to save a randomForests object (or other large objects) from R into a SQL database. 有没有办法将randomForests对象(或其他大对象)从R保存到SQL数据库中。 The only thing I can think of is to dsub the object and save it as a varchar(max) but was wondering if there's another way. 我唯一能想到的是dsub对象并将其保存为varchar(max)但是想知道是否还有其他方法。

The native way is to serialize the object using serialize() . 本机方法是使用serialize()序列化对象。 If your database supports binary objects, you can use the binary serialization, otherwise you can use rawToChar(serialize(x, NULL, ascii=TRUE)) to obtain a string. 如果数据库支持二进制对象,则可以使用二进制序列化,否则可以使用rawToChar(serialize(x, NULL, ascii=TRUE))来获取字符串。

Note that dput is inherently dangerous for storage because it allows arbitrary execution attacks. 请注意, dput对于存储本身就很危险,因为它允许任意执行攻击。

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

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