Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 50

4.3.1 The Elementary Types

Оглавление

There is no need to declare variables explicitly and tell R what type the variable will be before using it. R will assign them a class whenever this is needed and even change the type when our code implies a change.

class()

long

complex numbers

string

# Booleans can be TRUE or FALSE: x <- TRUE class(x) ## [1] "logical" # Integers use the letter L (for Long integer): x <- 5L class(x) ## [1] "integer" # Decimal numbers, are referred to as ‘numeric’: x <- 5.135 class(x) ## [1] "numeric" # Complex numbers use the letter i (without multiplication sign): x <- 2.2 + 3.2i class(x) ## [1] "complex" # Strings are called ‘character’: x <- "test" class(x) ## [1] "character"

The Big R-Book

Подняться наверх