Get startedGet started for free

What's that data type?

Do you remember that when you added 5 + "six", you got an error due to a mismatch in data types? You can avoid such embarrassing situations by checking the data type of a variable beforehand. You can do this with the class() function, as the code in the editor shows.

This exercise is part of the course

Introduction to R

View Course

Exercise instructions

Complete the code in the editor and also print out the classes of my_character and my_logical.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Declare variables of different types
my_numeric <- 42
my_character <- "universe"
my_logical <- FALSE 

# Check class of my_numeric
class(my_numeric)

# Check class of my_character


# Check class of my_logical
Edit and Run Code