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. 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 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. -- View this message in context: http://r.789695.n4.nabble.com/Object-not-found-using-GAMs-in-MGCV-Package-tp4301836p4301836.html Sent from the R help mailing list archive at Nabble.com.
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 foundYou 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
Hi, If "x" is your data, then gam(Atlantic ~ s(depth, bs="sos", k=4) + s(distance, bs="sos", k=4), data x) will do. See examples in ?gam. BTW, how did you read your data in R? What's the output of ls()? HTH, Jorge * * On Mon, Jan 16, 2012 at 6:29 PM, ruggeddon24 <> 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. > > 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 > > 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. > > -- > View this message in context: > http://r.789695.n4.nabble.com/Object-not-found-using-GAMs-in-MGCV-Package-tp4301836p4301836.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]