R Language Learning notes-statistical functions

Source: Internet
Author: User
Tags diff

There are many useful statistical functions in the R language. For example arithmetic averages:

Mean (x)

Find the average of x.

Mean (x, trim=0.05, Na.rm=true)
A truncated average is provided, which discards the data with a maximum of 5% and a minimum of 5% and the arithmetic averages after all missing values.

Common statistical functions provided by R:

function Describe
Mean (x) Average
Mean (c (1,2,3,4)) return value is 2.5
Median (x) Number of Median
Median (c (1,2,3,4)) return value is 2.5
SD (x) Standard deviation
SD (C (1,2,3,4)) return value is 1.29
var (x) Variance
VAR (c (1,2,3,4)) return value is 1.67
Mad (x) Absolute median difference (median absolute deviation)
Mad (C (1,2,3,4)) return value is 1.48
Quantile (X,probs) To find the number of bits. where x is the numerical vector of the number of probs to be divided into a probability value between [0,1]
The numerical vector
# 30% and 84% sub-sites for X
Y <-quantile (x, C (. 3,.84))
Range (x) Ask for a domain
x <-C (1,2,3,4)
Range (x) return value is C (1,4)
diff (Range (x)) The return value is 3
SUM (x) Sum
Sum (c (1,2,3,4)) returns a value of 10
diff (X, lag=n) Lag differential, lag is used to specify several lags. The default lag value is 1
x<-C (1, 5, 23, 29)
diff (x) return value is C (4, 18, 6)
MIN (x) To find the minimum value
Min (c (1,2,3,4)) return value is 1
Max (x) To find the maximum value
Max (c (1,2,3,4)) The return value is 4
Scale (X,center=true,
Scale=true)
Center (center=true) or standardize (Center=true,scale =true) for data object x by column;


R Language Learning notes-statistical functions

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.