R language Combat-Advanced data Management (1)

Source: Internet
Author: User

1. A data Processing challenge

A. Identification of a single achievement measurement indicator

B. The first 20% students are assessed as a, the next 20% is assessed as B, and so on

C. Sorting students alphabetically

2. Numeric and character processing functions

Numerical functions (mathematics, statistics, probabilities)

Character processing functions

2.1 Mathematical functions

2.2 Statistical functions

> Mean (C (1, 2, 3, 4)) [1] 2.5> > Median (C (1, 2, 3, 4)) [1] 2.5> > SD (C (1, 2, 3, 4)) [1] 1.290994> > var ( C (1, 2, 3, 4)) [1] 1.666667> > Mad (C (1, 2, 3, 4)) [1] 1.4826> > x <-C (1, 2, 3, 4) > y <-quantile (x, C ( .3,.)) > y 30%  84% 1.90 3.52 > > Range (x) [1] 1 4> > diff (Range (x)) [1] 3> > sum (x) [1] 10> ; x <-C (1, 5, max) > diff (x) [1]  4  6> > min (x) [1] 1> > Max (x) [1] 29> > scale (x, center= TRUE, Scale=true)           [, 1][1,] -0.9925397[2,] -0.6984539[3,]  0.6249324[4,]  

2.3 Probability function

> x <-Pretty (C ( -3, 3), +) > x [1] -3.0-2.8-2.6-2.4-2.2-2.0-1.8-1.6-1.4-1.2-1.0-0.8-0.6-0.4-0.2[16]  0.0  0.2  0.4  0.6  0.8  1.0  1.2  1.4  1.6  1.8  2.0  2.2  2.4  2.6  2.8[31]  

2.3.1 Set random number seed

2.3.2 Generating multivariate normal data

> Library (MASS) > Options (digits=3) # Generate random number seeds > set.seed (1234) # specify mean vector, covariance matrix > Mean <-C (230.7, 146.7, 3.6) > Sigma <-Matrix (C (15360.8, 6721.2, -47.1,+                    6721.2, 4700.9, -16.5,+                     -47.1,  -16.5,   0.3), nrow=3, NCOL=3) # generates 500 pseudo-random observation data > MyData <-mvrnorm (x, mean, sigma) # for convenience, results from matrix conversion to Data frame > MyData <-as.data.frame (mydata # Specifies a name for the variable > names (mydata) <-C ("Y", "x1", "X2") # confirms that it has 500 observations and 3 Variables > Dim (MyData) [1]   3# outputs the first 10 observations > head (M Ydata, n=10)       y    x1   x21   98.8  41.3 3.432  244.5 205.2 3.803  375.7 186.7 2.514  -59.2  11.2 4.715  313.0 111.0 3.456  288.8 185.1 2.727  134.8 165.0 4.398  171.7  97.4 3.649  167.2 101.0 3.5010 121.1  

2.4 Character processing function

R language Combat-Advanced data Management (1)

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.