Menu
Coddy logo textTech

Integer Data Type

Part of the Fundamentals section of Coddy's R journey — lesson 5 of 78.

While the numeric data type handles all kinds of numbers, R also has a specific integer data type for whole numbers. Integers are numbers without decimal points, like 1, 42, or 100.

To create an integer variable in R, you need to append the letter L to your number. This tells R that you specifically want an integer rather than the default numeric type:

count <- 5L
age <- 25L

The key difference is that 5 creates a numeric variable, while 5L creates an integer variable. Both store the same value, but R treats them as different data types internally. This distinction becomes important in certain programming situations where you need precise control over your data types.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals