"R language Combat" Reading notes--chapter II Creating datasets

Source: Internet
Author: User

2.1 Concepts of Datasets

Variable types are different, such as identifiers, date variables, continuous variables, nominal variables, ordered variables, etc., remember the introduction of data mining has a special description.

The types of data that R can handle include numeric, character, logical, complex (imaginary), native (byte).

2.2 Data structures

R has many object types that store data, including scalars, vectors, matrices, arrays, data frames, and lists. They can be represented by:

Factor is the nominal or ordered variable in R, which is very special.

2.2.1 Vector

A scalar is a vector of only one element, which is typically used to hold constants. Nothing else to say.

2.2.2 Matrix

Matrix creation Function:

1 1, Byrow = FALSE   , # Note The default padding    by column = NULL or (dimnames = list (rowname,colname))

On the matrix of the various algorithms, the book did not write, I do not, because the use of not much now, when used to see on the line, a bunch of online.

2.2.3 Array

I don't seem to have much to use, array function:

Array (data = NA, Dim = Length (data), Dimnames = NULL) #data是填充向量, Dim is a vector of dimensions, Dimnames is a name

Remember that there is a function for the row or column to the marginal sum, margin.table, and so on, when using the Baidu bar.

2.2.4 Data Frame

The book says this is the most commonly used data type, and it does use more. Data frame creation function Data.frame:

Data.frame (..., row.names = NULL, check.rows =           FALSE,= TRUE,           default= False.

Note Data frames are also generated by columns, and each column must have a consistent data type.

All right...... See the data Frame subscript reference, try it yourself, find a trick, see:

The above is a data frame, see the following experiment:

As can be seen, the data frame refers to a number, the representative directly refers to the column, the data frame, according to the way the Matrix to refer to the column, the resulting is a vector!! The way to refer to a row in a matrix is to get a data frame. The R language often encounters this kind of egg ache situation, must pay great attention. Of course, you can refer to a column with the $ symbol + column name (PS. Chinese state 4 above is ¥, USD for renminbi ...) ).

Here are a few functions that are useless. Learn a bit:

1.

"R language Combat" Reading notes--chapter II Creating datasets

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.