[R] Object not found using GAMs in MGCV Package
Sarah Goslee
sarah.goslee at gmail.com
Tue Jan 17 00:46:34 CET 2012
See inline:
On Mon, Jan 16, 2012 at 6:29 PM, ruggeddon24 <smithdon2469 at gmail.com> wrote:
> This is my first time running GAMs in R.
> My csv file has these column headings:
>
> "X" "Y" "Sound" "Atlantic" "Blacktip" "Bonnet"
> "Bull" "Finetooth" "Lemon" "Scalloped" "Sandbar" "Spinner"
> "Abundance" "Diversity" "Depth" "Distance" "Width" "System"
> "Channel" "Profile" "Bathy" "Slope" "Salinity"
> X is longitude and Y is Latitude.
Your csv file? You read it into R with read.table() or read.csv(), right?
> I typed in the code below and received the reply "Error in eval(expr, envir,
> enclos) : object 'Atlantic' not found".
>
>> library(mgcv)
> This is mgcv 1.7-6. For overview type 'help("mgcv-package")'.
>> help("mgcv-package")
> starting httpd help server ... done
>> gam(Atlantic ~ s(depth, bs="sos", k=4) + s(distance, bs="sos", k=4))
> Error in eval(expr, envir, enclos) : object 'Atlantic' not found
You need the data=mydataframe argument to gam(), with whatever the name
of your data frame is. Otherwise R has no idea where to look for Atlantic,
so it just looks for an object with that name, which there isn't.
> I do not have a clue how to fix this problem. Do I have too many variables
> or do I need to remove my x and y from the file? This data is being used to
> assess the spatial distribution of shark abundance in relation to
> environmental variables. I really cannot remove the x and y anyway. Help
> would be greatly appreciated.
Sarah
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list