CommencerCommencer gratuitement

Can you access variables from inside functions?

Suppose you ran this code in a fresh R session.

x_plus_y <- function(x) {
  x + y
}
y <- 7
x_plus_y(5)

Cet exercice fait partie du cours

Introduction to Writing Functions in R

Afficher le cours

Exercice interactif pratique

Passez de la théorie à la pratique avec l’un de nos exercices interactifs

Commencer l’exercice