Numbers in R

There are three nubmer types in R:

  • numeric
  • integer
  • complex

Example:

Numeric Data Type

Numeric data types are the most popular data types. Numeric data type is R may be represented as:

  • A whole number, such as 10
  • or a decimal or floating point number such as 10.5.

Integer Data Type

  • Integers are whole numbers without any decimal points
  • Integers must be created with the letter L at the end
  • Integers will never have decimals

Complex Data Type

complex number is written with an “i” as the imaginary part:

Numbers type Conversion

Examples

Interesting: as you can see from regarding converting from complex to numeric, it becomes zero. This is because the real part of the number is technically zero and the imaginary section is discarded.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top