What is R and why is it considered a vectorised, functional programming language?

Quick Overview

Asks what the R language is and why it is called a vectorised, functional language. Tests whether you understand element-wise operations and recycling, first-class functions and closures, the apply family, and where those labels stop being accurate.

What is R and why is it considered a vectorised, functional programming language?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

What is R, and why is it described as a vectorised, functional programming language? ```hint Two separate claims Treat "vectorised" and "functional" as two claims. For each one, name the language feature behind it and show it with a one-line example. ``` ### What a Strong Answer Covers - What R is and what it is mainly used for - What vectorisation means in R, including where the per-element loop actually runs and how recycling behaves - What makes R functional: functions as first-class values and the higher-order functions built on them - A short code example for each trait - The limits of both labels, such as apply-family functions still looping at the R level and R allowing side effects ### Follow-up Questions - Is `sapply()` faster than an explicit `for` loop? When would you expect a real speedup from rewriting a loop? - What happens when you add a vector of length 3 to a vector of length 5, and why does R warn? - How do closures work in R? Write a function that returns a function. - In what ways does R fall short of being a pure functional language?

Overview: Asks what the R language is and why it is called a vectorised, functional language. Tests whether you understand element-wise operations and recycling, first-class functions and closures, the apply family, and where those labels stop being accurate.

Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

What is R, and why is it described as a vectorised, functional programming language?

What a Strong Answer Covers Guidance

  • What R is and what it is mainly used for
  • What vectorisation means in R, including where the per-element loop actually runs and how recycling behaves
  • What makes R functional: functions as first-class values and the higher-order functions built on them
  • A short code example for each trait
  • The limits of both labels, such as apply-family functions still looping at the R level and R allowing side effects

Follow-up Questions Guidance

  • Is sapply() faster than an explicit for loop? When would you expect a real speedup from rewriting a loop?
  • What happens when you add a vector of length 3 to a vector of length 5, and why does R warn?
  • How do closures work in R? Write a function that returns a function.
  • In what ways does R fall short of being a pure functional language?