Using package nlme, I have model:
gls(temp.avg ~ year, data = df, method = 'ML')
This does exactly what I expect it to. However, when I create the model within a function with changing data argument for the gls function, my model no longer uses data 'df' but instead just prints "dat". Here is the function:
function(dat) { gls(temp.avg ~ year, data = dat, method = 'ML') }
Here is what it looks like when I view the model when created (first) outside of my wrapper function and then (second) when inside the function [Notice the "Data" line]:
Generalized least squares fit by maximum likelihood
  Model: temp.avg ~ year 
  Data: df 
  Log-likelihood: -3877.052
Coefficients:
   (Intercept)         (year) 
  15.135135363   -0.008796849 
Degrees of freedom: 1116 total; 1114 residual
Residual standard error: 7.807791
##########################
Generalized least squares fit by maximum likelihood
  Model: temp.avg ~ year
  Data: dat 
  Log-likelihood: -3877.052
Coefficients:
   (Intercept)         (year)  
  15.135135363   -0.008796849 
Degrees of freedom: 1116 total; 1114 residual
Residual standard error: 7.807791 
I'd really rather it not do that.
How can I get the function to carry over what I assign as dat vs "dat" itself?
 
    