na.gam.replace(frame)
The word "gam" in the name is relevant, because gam makes special use of this filter. All columns of a model frame that were created by a call to lo or s have an attribute names "NAs" if NAs are present in their columns. Despite the replacement by means, these attributes remain on the object, and gam takes appropriate action when smoothing against these columns. See section 7.3.2 in Statistical Models in S for more details.
gam(pick ~ s(income) + size, family = binomial, data = market.frame, na.action = na.gam.replace) # fit an additive model in the presence of missing datareplaced.data <- na.gam.replace(market.frame) attach(replaced.data)