# R code to demonstrate how functions are called in R and how they return # information to the calling code. # This is the calling code. # http://www.math.nyu.edu/faculty/goodman/teaching/MathFin/index.html # Author: Jonathan Goodman source("CalledCode.R") # Make the R interpreter read the definitions # functions in CalledCode.R. a = 2 b = 5 c = add( a, b) cat(" the sum of ", a, " and ", b, " should be ", c, "\n") d = 7*add( a*b, 1) cat(" 7*", a, "*", b, " +1 should be ", d, "\n") sad = add e =sad( 2, 3) cat("if sad is add, then 2 + 3 is ", e, "\n") cat( BirthdayWish( "Jonathan"))