Extract Object Created within User-Defined Function in R (Example Code)

This article demonstrates how to print an object created within a manually defined function in R.

Example: Manually Construct Function with Double Arrow

example_function <- function(my_input) {    # Constructing user-defined function
  my_output <<- my_input + 10
}
example_function(my_input = 1)              # Applying user-defined function
my_output                                   # Displaying output of user-defined function
# [1] 11

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top