Assignment and basic types

Assign values with <- or =. R has four atomic types: numeric, character, logical and integer. Use class() and typeof() to inspect, and is.* / as.* to test and coerce.

basics
# Assignment
x <- 42          # numeric
name <- "Alice"  # character
flag <- TRUE     # logical
n <- 5L          # integer

# Inspect type
class(x)         # "numeric"
typeof(flag)     # "logical"
is.numeric(x)    # TRUE
as.character(x)  # "42"

# Remove object
rm(x)
ls()             # list all objects in environment