I feel as if this is a fairly basic question, but I can\'t figure it out.
If I define a function in R, how do I later use the name of the function to get its parse tree.
Apparently that's indeed some weird quirk of substitute
and is mentioned here:
/* do_substitute has two arguments, an expression and an environment (optional). Symbols found in the expression are substituted with their values as found in the environment. There is no inheritance so only the supplied environment is searched. If no environment is specified the environment in which substitute was called is used. If the specified environment is R_GlobalEnv it is converted to R_NilValue, for historical reasons. In substitute(), R_NilValue signals that no substitution should be done, only extraction of promise expressions. Arguments to do_substitute should not be evaluated. */
And you have already found a way of circumventing it:
e = new.env()
e$fn = f
substitute(fn, e)