R Language Data Mining Combat series (2)

Source: Internet
Author: User
Tags odbc

R Language Data Mining Combat series (2)

Ii. Introduction to the language of R

The R language is a locale designed for statistical computation and graphical display, with free, multi-platform support, and the ability to import data from various types of data sources, with high openness and a high level of cartographic capabilities. R is a large-scale application software, mainly includes the core R standard package and other specialized areas of the package. R has a special advantage in the field of data analysis and data mining.

R Installation

R is available on its home page (https://www.r-project.org/) and is downloaded and installed according to the selected platform. Start R after installation is complete. For easy use of R, you can use the Free graphical interface Editor Rstudio, which can be downloaded and installed from https://www.rstudio.com/.

Getting Started with R

The R software interface is similar to other programming software, and consists of a number of menus and shortcut buttons.

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/97/31/wKioL1kqi6yh-s80AAD2FRlR4sM711.jpg-wh_500x0-wm_ 3-wmp_4-s_1102483835.jpg "title=" qq20170528163429.jpg "alt=" Wkiol1kqi6yh-s80aad2frlr4sm711.jpg-wh_50 "/>

The File menu can be implemented by entering R code, creating new program scripts, opening program scripts, displaying files, loading workspaces, saving workspaces, loading history, saving history, changing the current directory, printing, saving to files, and exiting functions; the Edit menu enables copying, pasting, Clear console and data editing functions; The View menu allows you to choose whether to display toolbars; the "Other" menu allows you to interrupt current calculations, buffer output, and list target objects; The package menu enables loading of packages, setting up Cran mirroring, installation, and update packages; windows The menu has the option to cascade or tile all windows, and the Help menu provides a common answer and help path for R.

Toolbars Open program scripts, load images, save images, copy, paste, copy and paste, terminate current calculations, and print operations from left to right.

The command Window ">" is a command prompt indicating that R is in the state of preparation for editing, and the user can enter the command statement directly at the command prompt and press "enter" key to execute.

Rstudio Introduction

The Rstudio window is composed of code edits, command consoles, resource bars, and other columns.

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/97/32/wKioL1kqjmjj0soJAAJx6R7SI1o234.jpg-wh_500x0-wm_ 3-wmp_4-s_2706234475.jpg "title=" qq20170528164607.jpg "alt=" Wkiol1kqjmjj0sojaajx6r7si1o234.jpg-wh_50 "/>

R Common Operations

(1) Help

Features: Provides online Help for r functions and R files.

In the Command window, enter help (function name), or? Function name, press "enter" key to execute, or the search Help pop-up box under the Help menu of R to enter the function name, you can open the helper browser.

There are 6 parts in the use Help: Description (function Description) section describes the function's main function, the Usage section gives the function's calling method, and the Arguments (parameter) section gives a detailed explanation of the input parameters, including the value range of the input parameters, Data format, etc. the Detail (Details) section gives the information related to the function; see Also (Other) section provides links to other functions related to the function, and Examples (example) section gives a common example of the function, the user can directly run the sample program to get the results, Get an intuitive impression of the function. Some of the functions of the Help document also includes: Value (output parameters) section gives a detailed description of the output parameters; Reference (reference) The research literature of this function is given.

(2) Ctrl+l

Function: Clears all display contents in the Command window.

(3) RM (List=ls ())

Function: Clears the memory variables in the R workspace. The RM (List=ls ()) command is generally used with the GC () command to clear memory variables and free up memory space.

(4) Install.packages, library

Function: Install.packages () is used to download and install the package; the library () function can not only show which packages are in the library, but also load the downloaded package and use the package in the session.

(5) GETWD (), SETWD ()

Function: Gets or sets the location of the current working directory.

(6) Save, load

Function: Save saves the specified object in the R workspace to the executing file; Load reads a workspace from the disk file into the current session.

(7) Read.table, write.table, Read.csv, Write.csv

Functions: read.table, Read.csv read Excel, txt or CSV file to the current workspace, write.table, Write.csv writes data from the current workspace to an Excel, TXT, or CSV file.

(8) Odbcconnect, SqlFetch, sqlquery

Function: Odbcconnect establishes a connection to an ODBC database; SQLFetch reads a table from an ODBC database into a data frame of R; sqlquery an ODBC database submits a query and returns the result.

(9) Source, sink

Function: Source ("filename") can execute a script in the current session; Sink ("filename") redirects the output to the file filename.

(Ten) plot

Function: Drawing, can set parameters for custom image drawing.

R Data Analysis Package

The main categories of r packages include spatial data analysis, machine learning and statistical learning, multivariate statistics, pharmacokinetic data analysis, econometrics, financial analysis, parallel computing, and database access classes.

Function Functions and loading packages
Classification The nnet () needs to load the BP neural network nnet Packet; Randomforest () needs to load the random forest randomforest package; the SVM () needs to load the e1071 package; the tree () needs to load the cart decision Trees tree package, etc.
Clustering Hclust () function, Kmeans () function
Association Rules Apriori () need to load Arules package
Time series Arima () needs to load forecast, Tseries packages

This article is from the "Rangers" blog, please be sure to keep this source http://ccnupxz.blog.51cto.com/8803964/1930493

R Language Data Mining Combat series (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.