1, R connection database
Step1: Download Rodbc. In console: Install.packages ("RODBC")
The downloaded RODBC package needs to be loaded into the rstudio before use. Tools->import Dataset.
Specify DSN: Call Odbcad32.exe (typically under C:\Windows\System32), click Add, select MySQL ODBC 5.2 ANSI Driver (choose a different drive depending on MySQL), and fill in the configuration as prompted. Application--Complete.
Step2:library (RODBC):
Mysql<-odbcconnect ("Baidu_lbs_data", uid= "root", pwd= "");
Baidu_lbs_data for Database name
SqlTables (MySQL); To read a table in a database
SQLQuery (MySQL, "select * from XXX"); SELECT statement
Sqldrop (MySQL, "XXX");//Delete table
Odbcclose (MySQL);//Close Database
SqlFetch (MySQL, "XXX", Rownames = "state")//contents of the output table
Data (XXX)//write table to database
Sqlsave (mysql,xxx,rownames = "state", ADDPK = TRUE)//Save data stream, new XX table
RM (XXX)
2. R Drawing
Plot ()
Lines when you draw multiple lines in a diagram
Grid adding rasters to graphs
Abline Add a line
Legend adding a legend
Save a picture in a corresponding format
such as PNG (file= "Myplot.png", bg= "Transparent"), #R code Dev.off ( ) jpeg (file= "myplot.jpeg") #R code Dev.off ( ) PDF (file= "myplot.pdf") #R Code Dev.off ()
Note: Dev is device
3.
R study Notes (1) 2015-4-23