Introduction to R language

Source: Internet
Author: User

Vectors are the most basic type of data in R, and there are no separate scalars in R (for example, 1 is C (1) in nature) Note that the subscript for R is a negative number starting with 1 that does not select these subscripts, for example:
> A <-C (2,5,8)
> A[-2]
[1] 2 8
The loop-up vector has a more interesting property, when two vectors are operated, if the length is not equal, the shorter one will copy itself until it is as long as it is long.
> A <-C (3,4)
> B <-C (1,2,5,6)
> A+b
[1] 4 6 8
Create a new matrix
> A <-matrix (c (1,2,3,4), nrow = 2)
> A
[, 1] [, 2]
[1,] 1 3
[2,] 2 4
You can see that the vector element becomes a matrix element in columns, from the first column to the second column, if we want to enter the element by row, then we need to add Byrow = True parameter in R we add two percent sign to multiply next to multiplication:
> a%*%a
[, 1] [, 2]
[1,] 7 10
[2,]
In general we need to analyze the data, each row represents a sample, each column represents a variable

Introduction to R language

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.