2.4.1 Basic Data Types

x = 3.14; y = 2
class(x)
class(y)

This is a sample sentence with an annotated text that shows additional information on hover.

x = 5L; y = c(1L, 2L)
class(x)
class(y)
x = 1 + 2i
class(x)
x = "Machine Learning"
class(x)
x = TRUE; y = FALSE
class(x)
class(y)
x & y # '&' is the AND operator
x | y # '|' is the OR operator
x + y # Can we calculate it?
x/y # And this?

Remark: if you apply basic arithmetic operators to logical values, then they will be transformed to numeric first, and then execute the calculations.

Previous page | Lecture 2 Homepage | Next page

© 2024 Xijia Liu. All rights reserved.
Logo