Solution Review: Variables

In this review, we give a detailed analysis of the solution to this problem.

Solution: Use class() and typeof()

Press + to interact
testVariable <- 1.9
# getting high level data type with class() and low level data type with typeof
cat(class(testVariable), typeof(testVariable))

Explanation

The first task we were given was to find the high-level data type of the given testVariable. We can do this by using the class() function with the given testVariable. The second task was to print the low-level data type of the testVariable and for that, we use the typeof() function with the testVariable.

A function is a set of instructions that perform a task. We will learn more about functions later in the course.

We pass both these functions to cat() for printing.