R language data structure--2 matrix and data frame ① matrix-matrix

Source: Internet
Author: User

Matrix-matrix-2018 June 9

Today is a pity, not too much to learn R language (mainly because to listen to party lecture, learned the party important speech, so no reading), so today summed up a matrix bar. But more study.

First of all, a little review of yesterday's factor, the first thing to remember is mode () look at each element, class () see what is the whole, and if you put true ABC 1 to a vector, the vector will convert it to type. Security: String > Numeric > logical value. Will try to convert to a high level of security. This is an implicit type conversion. Of course, you can also use the as family for type conversions, such as converting numbers to strings: As.character () (can be remembered as Char+acter)

Next, The Matrix

A matrix is an extension of an object's amount, a vector is a one-dimensional structure, and a matrix is a two-dimensional structure, and all element types must be the same.

1: How to create a matrix

Matrix ()

You can also make changes to the vector Dim property

You can also assemble a number of vectors into a matrix, or you can synthesize a matrix of matrices: matrix, and matrices can add row names and column names to make it easier for us to find the data without having to count the number of rows he is in the first row. (Of course you want to use which to find me and don't talk!) )

First, if you learn linear algebra, it is easy to understand what the matrix is, such as the decomposition of the matrix, like to multiply and so on in R.

So formally, create the matrix:

(1), Create Na matrix (review na for missing values)

(2), create a worthy

Priority by line

(3) Assembly

Look at mode and class.

R language data structure--2 matrix and data frame ① matrix-matrix

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.