R-Big Data analysis and Mining (5-r Basic Review)

Source: Internet
Author: User
Tags cairo cairo package

(i) r function

R is an analytic language, which can be obtained directly after input.

Functions (Input parameters, parameters)

Functions of R are divided into "advanced" and "low-level functions"
• Advanced functions can call low-level functions
• High-level functions are called generic functions

• Function name <-‐funcion (data, parameter = 1, default value) {
•? Exception handling
•? An expression
•? return value
•?}

(b) r Assignment and annotation

?2+2
?a <-‐2
?c <-‐a+b

• #注释

(iii) Name of the object

?1. Case-sensitive, China differs from China
?2. You cannot use numbers as variables, and objects cannot start with numbers
?3. Reserved words
–? Na,nan,pi,letters,lebers,month, etc.

(iv) Types of elements

• Numerical type, Numeric
• String, Character
• Logic Type, Logical
• Factor type, Factor
• Plural type, Complex such as 2+3i

• Vectors (vector), a series of elements
–? C (n/a); C ("A", "a", "B", "B", "C")
• Factor (factor) factor is a categorical variable
?c ("A", "a", "B", "B", "C")
• Matrix, a two-dimensional data table, is a special case of an array

• Arrays (array)
– The array is a K-dimensional data table (k in 1:n, n is a positive integer)
• Data Frame (dataframe)
– is made up of one or several vectors and factors, they must be equal, but can be different but data types
• List
– The list can contain any type of object
– can contain vectors, matrices, high-dimensional arrays can also contain lixt

Operator

• Mathematical operations
–?+,-‐===
• The comparison operation returns TRUE or False
–?>,<,<=,>=,==
• Logical Operations
–?!, &,&&,|,| |

External Data Read

?read.table ()
?read.csv () read CSV or
• Format data such as Excel can be read directly from some packages

?read.csv (' file ', header=t)
–?header=t represents the first row of data as the title

The judgment of the class

?mode () determine the type of storage
?class (), judging the class of the data

?is.numeric ()
?is.logical ()
?is.charactor ()

References to elements within a data frame

?intake <-‐data.frame (intake.pre,intake.post)
?1. $ reference column, followed by the name of the column
– for example: intake$ intake.pre
?2. [,] square brackets, comma before line, comma after column
?intake[,1]
•? i = 1:5;intake [I,]

Conversion of Classes

?as.numeric ()
?as.logical ()
?as.charactor ()
?as.matrix ()
?as.data.frame ()
?as.factor ()

(v) r operation JSON

1. Install JSON

2. Loading into the GUI

3. Go from JSON to R

4. Class judgment type, cat output a JSON string without a horizontal line, peint output with/, can be taken through the deep JSON string, the most inner can be used [] to get

5. Export the Tojson string to a file using sink or Writelines

(vi) R language is not only powerful in the field of statistical analysis and data mining, but also in the field of data visualization.
Expensive commercial software. Of course, R is powerful in visualization, it is inseparable from the support of various open source software packages, Cairo
That's it. A class library for vector graphics processing. Cairo can create high-quality vector graphics (GIF, SVG,
PDF, PostScript) and bitmaps (PNG, JPEG, TIFF), while supporting high-quality rendering in background programs! This section
Describes the use of Cairo in the R language.

1. Installation

2. Load into the GUI and check the image format supported by the Cairo package

3. Draw Scatter chart

(vii) Time Series Foundation Library in R. Zoo

Time series analysis is a statistical method of dynamic Data processing, through the analysis of time series data, we can
To feel what the world is changing! As a powerful tool of statistical analysis, R language has strong support for time series processing.
Hold. In the R language, a data type Zoo,zoo is the basis of a time series that is defined separately for time series data.
is also the basis for stock analysis. This section describes the structure and use of the Zoo Library in the R language.

1. Introduction

Zoo is an R language library, the Zoo Class Library defines a S3 type object named Zoo, used to describe the rules
and irregular ordered time series data. Zoo object is a separate object, including index, date, time
dependent on the underlying R environment. The Zooreg object inherits the zoo object and can be used only for the time series data of the rule.
Many other packages in the R language are based on the zoo and Zooreg as time series data!

Zoo Package API has 6 main categories

(1) Base Object
? Zoo: An ordered sequence of time objects.
? Zooreg: A regular time series object that inherits Zoo objects. Compared to the zoo, the difference is that Zooreg requires data to be continuous.
(2) Type conversion
? As.zoo: Transforms an object into a zoo type.
? Plot.zoo: Provides the zoo interface for the plot function.
? Xyplot.zoo: Provides the zoo interface for the lattice Xyplot function.
? Ggplot2.zoo: Provides the zoo interface for the GGPLOT2 package.
(3) Data manipulation
? CoreData: View or edit the data section of the zoo.
? Index: View or edit the indexed portion of the zoo.
? Window.zoo: Filter data by time.
? Merge.zoo: Merges multiple Zoo objects.
? Read.zoo: Read and write the zoo sequence from a file.
? Aggregate.zoo: Calculates zoo data.
? Rollapply: Scrolling processing of zoo data.
? Rollmean: Calculates the mean value for the scrolling of zoo data.
(4) NA value processing
? The padding for the Na.fill:NA value.
? NA.LOCF: Replace the NA value.
? Na.aggregate: Calculates the statistic value to replace the NA value.
? Na.approx: Calculates the interpolation to replace the NA value.
? Na. Structts: Calculates the seasonal Kalman filter to replace the NA value.
? Na.trim: Filtered records with NA.
(5) Auxiliary tools
? Is.regular: Checks if the sequence is a rule.

? Lag.zoo: Calculates the step size and differential.
? MATCH: Takes intersection.
? Order: Value sort, output index.
(6) Display control
? Yearqtr: Displays the time in the year quarter.
? Yearmon: Displays time in years.
? Xblocks: Plots are plotted along the x-axis.
? Make.par.list: Used to convert Plot.zoo and xyplot.zoo data formats.

  

R-Big Data analysis and Mining (5-r Basic Review)

Related Article

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.