← Back to R Course | Chapter 2: Variables & Types | Lesson 2 of 7

Numeric Type

In this page:

  1. Numeric Type

Numeric Type

numeric is R's default type for any number, storing values as double-precision floating point regardless of whether they look like whole numbers. Most arithmetic in R produces numeric results. Use class() or typeof() to check a value's actual type.

Note: Even x <- 5 (no decimal point) creates a numeric (double), not an integer, unless you explicitly use 5L.

Example: Numeric Type

markup
x <- 5
y <- 5.5

cat(class(x), class(y), "\n")
cat(x + y, "\n")
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.