[R] Object not found using GAMs in MGCV Package
Don McKenzie
dmck at u.washington.edu
Tue Jan 17 03:38:43 CET 2012
And note how Michael has changed your code so that your data object
is now named "Final" instead of "Final.csv".
On 16-Jan-12, at 5:16 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> That should work: you are using it before the call to gam?
>
> Try this (verbatim)
>
> library(mgcv)
> Final <- read.csv("Final.csv")
>
> ls.str()
> search()
> sessionInfo()
>
> gam(Atlantic ~ s(depth, bs="sos", k=4) + s(distance, bs="sos",
> k=4), data = Final)
>
> and give the output.
>
> Michael
>
> On Jan 16, 2012, at 7:13 PM, Dontrece Smith
> <smithdon2469 at gmail.com> wrote:
>
>> I used:
>>
>>> Final <- read.csv("Final.csv", header=TRUE)
>>
>>
>> On 1/16/12, Jorge I Velez <jorgeivanvelez at gmail.com> wrote:
>>> Hi Dontrece,
>>>
>>> It looks like you do not have an object "Final" in your active
>>> session.
>>> Could you please show us how you read your data, e.g., what
>>> commands you
>>> used and what's the result of ls()?
>>>
>>> As Sarah Goslee mentioned in an earlier post, you probably used
>>> read.table() or read.csv() but you haven't told us (yet).
>>>
>>> Regards,
>>> Jorge.-
>>>
>>>
>>> On Mon, Jan 16, 2012 at 7:04 PM, Dontrece Smith <> wrote:
>>>
>>>> Now, it read this:
>>>>
>>>>> library(mgcv)
>>>> This is mgcv 1.7-6. For overview type 'help("mgcv-package")'.
>>>>> gam(Atlantic ~ s(depth, bs="sos", k=4) + s(distance, bs="sos",
>>>>> k=4),
>>>> data = Final)
>>>> Error in inherits(x, "data.frame") : object 'Final' not found
>>>>
>>>>
>>>> On 1/16/12, Jorge I Velez <jorgeivanvelez at gmail.com> wrote:
>>>>> 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 at 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.
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dontrece Smith
>>>> Graduate Student
>>>> Savannah State University
>>>> 4906 Taylor Road
>>>> Savannah, GA 31404
>>>> (770) 401-3371
>>>>
>>>
>>
>>
>> --
>> Dontrece Smith
>> Graduate Student
>> Savannah State University
>> 4906 Taylor Road
>> Savannah, GA 31404
>> (770) 401-3371
>>
>> ______________________________________________
>> R-help at 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]]
>
> ______________________________________________
> R-help at 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.
Don McKenzie, Research Ecologist
Pacific Wildland Fire Sciences Lab
US Forest Service
phone: 206-732-7824
Affiliate Professor
School of Environmental and Forest Sciences
University of Washington
More information about the R-help
mailing list