Logical (0) and numeric (0) and assignment problems in the R language

Source: Internet
Author: User

Logical (0) is not equal to numeric (0). Both are not equal to null values, i.e. Is.null (logical (0)) and is.null (numeric (0)) return values are false. It is interesting to note that a zero-length value is sometimes not counted as a null value, but the definition of a null value is a parameter that is not assigned in the function, and is characterized by no value. How do I differentiate between null and NA? Very simple, the latter logical length is 1, while the former logical length is 0, meaning that if you use is.logical to determine the logical value of NA, the resulting result is true. Na can be positive infinity or negative infinity, but null always represents the concept of an empty set without this value.

Summing up the return value of is.logical (condition), the condition in parentheses is the following state:

1. Numeric (0) = = Numeric (0) and numeric (0)! = Numeric (0), returns True.

2. Logical (0), numeric (0), NULL, returns false.

3. NA, returns True.

Null there is also a problem, that is, if the condition of the If-else loop, if the occurrence of the variable is "assigned" is Null,numeric (0), or logical (0), the error message says that the length of the assignment can not be zero. The tricky here is that, although logical (0) and numeric (0) are not NULL objects, they are not logical values because the "length" of the three is zero.

Logical (0) and numeric (0) and assignment problems in the 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.