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