Solution Review: Vectors and Lists

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

Solution: Using is.recursive()

Press + to interact
testVariable <- list(1, 1+1i, "a", TRUE)
cat(is.recursive(testVariable))
cat("\n")
testVariable <- c(1, 2, 3, 4)
cat(is.recursive(testVariable))

Explanation

The method is.recursive() with the testVariable can tell us whether the object being passed is recursive or not. Here, list is recursive, while vector is not recursive. Later, we can print using cat().