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

R语言中RMySQL的简单应用_MySQL

WBOY
Release: 2016-06-01 13:01:22
Original
1794 people have browsed it

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

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

安装RMySQL包

install.packages("RMySQL")
Copy after login

加载

 library(RMySQL)
Copy after login

建立连接

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

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

dbWriteTable(conn, "tablename", data)
Copy after login

读表同理

dbReadTable(conn, "tablename")
Copy after login

关闭连接

dbDisconnect(conn)
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template