R language: Common function "Go"

Source: Internet
Author: User
Tags diff mathematical functions square root

Data

First, data management
Vector: vectors
Numeric: Numerical vector
Logical: Logical vector
Character: vector of character type
List: Lists
Data.frame: Data Frame
C: Connect as a vector or list
Length: Ask for Lengths
Subset: Seeking subsets
Seq,from:to,sequence: Linear sequence
Rep: Repeat
NA: Missing value
Null: Empty Object
Sort,order,unique,rev: Sort
Unlist: Flatten List
Attr,attributes: Object Properties
Mode,typeof: Object storage mode and type
Names: object's name attribute

Second, string processing
Character: vector of character type
NCHAR: Number of characters
SUBSTR: Take a substring
Format,format C: Convert an object to a string in a format
Paste,strsplit: Connecting or splitting
Charmatch,pmatch: String Matching
Grep,sub,gsub: pattern matching and substitution

Third, plural
Complex,re,im,mod,arg,conj: Complex function

Iv. factors
Factor: Factor
Codes: Encoding of the factor
Levels: The names of the various levels of the factor
Nlevels: Number of levels of factors
Cut: Converting a numeric object partition to a factor
Table: cross-frequency tables
Split: Grouping by factor
Aggregate: Calculating a generalized statistic for each subset of data
Tapply: Applying a function to an "irregular" array



Math-related calculations

First, the calculation
+,-, *,/, ^, percent,%/%: arithmetic
Ceiling,floor,round,signif,trunc,zapsmall: Rounding
Max,min,pmax,pmin: Maximum minimum value
Range: Maximum value and minimum value
Sum,prod: vector Elements and product
Cumsum,cumprod,cummax,cummin: Cumulative, multiplicative
Sort: Sorting
Approx and approx fun: interpolation
diff: Differential
Sign: Symbolic function

Second, mathematical functions
ABS,SQRT: Absolute value, square root
LOG, exp, log10, log2: logarithmic and exponential functions
SIN,COS,TAN,ASIN,ACOS,ATAN,ATAN2: Trigonometric Functions
Sinh,cosh,tanh,asinh,acosh,atanh: Hyperbolic function
Beta,lbeta,gamma,lgamma,digamma,trigamma,tetragamma,pentagamma,choose, Lchoose: Special functions related to beta functions, gamma functions, and combinatorial numbers
Fft,mvfft,convolve: Fourier transform and convolution
Polyroot: The polynomial root-finding
Poly: Orthogonal polynomial
Spline,splinefun: Spline Difference value
Besseli,besselk,besselj,bessely,gammacody:bessel function
Deriv: Symbolic differentiation or algorithmic differentiation of simple expressions

Three, array
Array: Creating arrays
Matrix: Generating matrices
Data.matrix: Converting a data frame to a numeric matrix
Lower.tri: The lower triangular part of the matrix
Mat.or.vec: generating matrix or vector t: Matrix transpose
Cbind: Merging columns into matrices
Rbind: Merging rows into matrices
Diag: vector of matrix diagonal elements or generation of diagonal matrices
Aperm: Array Transpose
Nrow, Ncol: Calculating the number of rows and columns of an array
Dim: The dimension vector of the object
Dimnames: The dimension name of the object
Row/colnames: Row or column name
%*%: Matrix multiplication
Crossprod: Matrix cross product (inner product)
Outer: Array Outer product
Kronecker: Kronecker product of an array
Apply: Apply functions to some dimensions of an array
Tapply: Applying a function to an "irregular" array
Sweep: Calculating the generalized statistics of an array
Aggregate: Calculating a generalized statistic for a subset of data
Scale: Matrix Normalization
Matplot: Plotting the columns of a matrix
Cor: correlation matrix or covariance matrix
Contrast: Control matrix
Row: The line subscript set of the matrix
Col: Find column subscript set

Four, linear algebra
Solve: Solving a linear equation group or seeking inverse
Eigen: Eigenvalue decomposition of matrices
SVD: Singular value decomposition of matrices
Backsolve: to the upper triangular or lower trigonometric equation Group
Chol:choleski decomposition
QR: QR decomposition of matrices
CHOL2INV: from Choleski decomposition to inverse

Five, logical operation
<,>,<=,>=,==,!=: comparison operator
!,&,&&,|,| |,xor (): logical operator
Logical: Generating Logical vectors
All,any: Logical vectors are true or exist
IfElse (): Alternatively
match,%in%: Find
Unique: Finding distinct elements
Which: Find the truth subscript set
Duplicated: Duplicate elements found

Vi. optimization and root-finding
Optimize,uniroot,polyroot: one-dimensional optimization and root-finding




Programming

First, control structure
If,else,ifelse,switch: Branch
For,while,repeat,break,next: Cycle
Apply,lapply,sapply,tapply,sweep: The function that replaces the loop.

Second, functional aspects
function: Functions definition
Source: Call File
Call: Function calls
. C. FORTRAN: A dynamic link library that calls C or FORTRAN subroutines
Recall: Recursive invocation
Browser,debug,trace,traceback: Program Debugging
Options: Specifying System parameters
Missing: Determining if a virtual parameter has a corresponding argument
Nargs: Number of arguments stop: terminate function execution
On.exit: Specifies execution when exiting
Eval,expression: Expression evaluation
System.time: Expression Calculation timing
Invisible: Make variable not display
Menu: Select Menus (character list menu)
Other functions related to the function are: Delay,delete.response,deparse,do.call,dput,environment, formals,format.info,interactive,
Is.finite,is.function,is.language,is.recursive, Match.arg,match.call,match.fun,model.extract,name,parse,substitute,sys.parent, Warning,machine

Iii. Input and output
Cat,print: Display Object
Sink: Output steering to specified file
Dump,save,dput,write: Output Object
Scan,read.table,load,dget: Read in

Iv. Working Environment
Ls,objects: Display Object list
RM, remove: Delete Object
Q,quit: Exiting the system
. First,. Last: The initial run function and exit run function.
Options: System option
?, Help,help.start,apropos: Help Features
Data: List datasets




Statistical analysis

I. Statistical distribution
Each distribution has four functions: d――density (Density function), p―― distribution function, Q―― division function, r―― random number function.
For example, these four functions of a normal distribution are dnorm,pnorm,qnorm,rnorm
Lists the distribution suffixes, preceded by the prefix D, p, Q, or R to form the function name:
Norm: normal state
T:t distribution
F:f distribution
CHISQ: Chi-square (including non-center)
UNIF: Uniform
Exp: Index
Weibull: Weibull
Gamma: Gamma
Beta: bell tower
Lnorm: Logarithmic normality
Logis: Logical Distribution
Cauchy: Cauchy
Binom: Two distributions
Geom: Geometric distribution
Hyper: Super Geometry
Nbinom: Minus two items
POIs: Poisson
Signrank: Symbol rank,
Wilcox: Rank sum
Tukey: Very poor student

Second, simple statistics
Sum, mean, Var, sd, Min, max, range, median, IQR (four cent spacing) for statistics
Sort,order,rank is related to sorting, other ave,fivenum,mad,quantile,stem, etc.

Third, statistical testing
Chisq.test,prop.test,t.test implemented in R

Iv. Multivariate analysis
Cor,cov.wt,var: Covariance matrix and correlation matrix calculation
Biplot,biplot.princomp: Multivariate data biplot graph
Cancor: The code is relevant
Princomp: Principal component Analysis
Hclust: Genealogy Clustering
kmeans:k-mean-value clustering
Cmdscale: Classic Multidimensional scale others have Dist,mahalanobis,cov.rob

Five, Time series
TS: Time Series objects
diff: Calculate differential
Time: Sampling time for a timeseries
Window: Time window

VI. Statistical Models
Lm,glm,aov: Linear model, Generalized linear model, variance analysis





File operations

I. Implementation of the document:
After generating a PDF document with R, if you want to open it, you may find it in the folder and open it again. Or if we want to invoke other programs in the system to do something, you might want to open the cmd Strike Command. In fact, this can all be done inside R. For example, convert na.md into docx with Pandoc and open it.
System (' Pandoc d:\\rspace\\na.md-o d:\\rspace\\na.docx ')
Shell.exec (' D:\\rspace\\na.docx ')


Second, web browsing:
Browseurl: Browse for a specific page
Download.file: Download network files to local

Third, file operation
Dir.create: Create a new Folder
List.dirs: Show folders under Directory
List.files: Show documents in Directory
File.create: Document Creation
File.exists: Determining whether a document exists
File.remove: Document Deletion
File.rename: Renaming
File.append: Document Additions
File.Copy: Document Replication
File.symlink (from, to)
File.show: Displaying document content
File.info: Displaying Document information
File.edit: Editing a document
Zip: Compressed file
Unzip: Extracting files

Iv. Operation Progress Bar
In a cycle operation, if you can see the current progress is more convenient, txtprogressbar and Settxtprogressbar functions can help to do this

R language: Common function "Go"

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.