Skip to content
Prev 165163 / 398506 Next

understanding recursive functions

I am by no means an expert in programming so I will defer to the experts. But assuming the OP was not intentionally trying to assign in a parent environment, couldn't the above function be written as

q <- function(x,h){if (x < 2) q(x+h,h) else return(x)

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204