Home >Database >Mysql Tutorial >R语言中RMySQL的简单应用_MySQL

R语言中RMySQL的简单应用_MySQL

WBOY
WBOYOriginal
2016-06-01 13:01:221790browse

有时候用R处理数据的时候想随便把数据存到数据库中,那样用mysql联合查询起来会方便很多

可以用RMySQL包,导入导出蛮简单的

安装RMySQL包

install.packages("RMySQL")

加载

 library(RMySQL)

建立连接

conn <- dbConnect(MySQL(), dbname = "rmysql", username="rmysql", password="rmysql",host="127.0.0.1",port=3306

然后写入数据库直接用这个函数就行了

dbWriteTable(conn, "tablename", data)

读表同理

dbReadTable(conn, "tablename")

关闭连接

dbDisconnect(conn)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn