R Language Beginner Experience

Source: Internet
Author: User

Experienced programmers often find some aspects of the R language unusual. Here are some of the features you need to know in this language:

1, the period (.) in the object name has no special meaning. But the dollar sign ($) has a similar meaning to a period in other languages, which is to specify parts of an object

For example:

(1) a$x refers to the variable x in data frame A.

(2) lm.x refers to a variable, lm$x refers to an object LM property.


2, R does not provide multi-line comment or block annotation function

You must start with # as a multiline comment for each line. For debugging purposes, you can also put code that you want the interpreter to ignore in the statement if (FALSE) {...} In Change false to True, which allows the code to execute.


3. When you assign a value to a vector, matrix, array, or a nonexistent element in a list, R automatically expands the

Data structures to accommodate the new values.

For example,

(1) Consider the following code:

By assigning a value, vector x is expanded from three elements to seven elements.

x <-X[1:3] will re-shrink it back to three elements.

(2) in the data frame, if the length of a column vector input is not enough, it is automatically populated.


4, there is no scalar in R. Scalar appears as a single-element vector


5, the subscript in R does not start from 0, and starting from 1

In the above vector, the value of x[1] is 8.


6. Variable cannot be declared

They are generated when the value is first assigned.


R Language Beginner Experience

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.