[R] How to deal with this :" object ' obs' not found.
P Ehlers
ehlers at ucalgary.ca
Sat Oct 3 04:16:11 CEST 2009
Oops, missed a square bracket:
ttx1[order(-ttx1[,"obs"]),]
-Peter Ehlers
P Ehlers wrote:
> You don't need to attach. But you do need to mention what kind of
> object ttx1 is. I had (foolishly) assumed that it was dataframe,
> but I see that it's a matrix. So try this:
>
> ttx1[order(-ttx1[,"obs"),]
>
> -Peter Ehlers
>
> Hyo Lee wrote:
>> Ok. I just figured out what the problem was.
>> I had to attach() the data.
>> **
>> x1=data1[,,2]
>> tx1=t(x1)
>> *ttx1 *= cbind(tx1 , obs=1:nrow(tx1))
>> --> this is how ttx1 was made; and of course, in ttx1, there is a
>> variable
>> called 'obs'.
>>
>> I had to attach(ttx1) first before I use this:
>> *sortedx1=ttx1[order(-obs),]*
>>
>> But it seems that, I cannot attach ttx1.
>> *> attach(ttx1)
>> Error in attach(ttx1) :
>> 'attach' only works for lists, data frames and environments*
>>
>> Of course, this is one of the ways I can do. But I just don't think I
>> can do
>> it for 1916 times.
>>
>>> write.csv(ttx1,"c:/i.csv")
>>> m=read.table("c:/i.csv", header=T, sep=",")
>>> attach(m)
>>> sortedx1=m[order(-obs),]
>>>
>> Do you know what I should do?
>> Thanks.
>>
>> -Hyo
>> On Fri, Oct 2, 2009 at 8:50 PM, jim holtman <jholtman at gmail.com> wrote:
>>
>>
>>> It is clear that 'obs' does not exist.
>>>
>>> On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee <totemo13 at gmail.com> wrote:
>>>
>>>> It says...
>>>>
>>>>
>>>>> str(obs)
>>>>>
>>>> Error in str(obs) : object 'obs' not found
>>>>
>>>>> ls(obs)
>>>>>
>>>> Error in try(name) : object 'obs' not found
>>>> Error in as.environment(pos) : no item called "obs" on the search list
>>>>
>>>> On Fri, Oct 2, 2009 at 8:26 PM, jim holtman <jholtman at gmail.com>
>>>> wrote:
>>>>
>>>>> Are you really sure you have 'obs'? What does 'str(obs)' show? What
>>>>> about 'ls()'?
>>>>>
>>>>> On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee <totemo13 at gmail.com> wrote:
>>>>>
>>>>>> Hi guys,
>>>>>> I need your help.
>>>>>> I'm trying to sort the data by the variable "obs".
>>>>>> This is how I tried to sort the data below.
>>>>>>
>>>>>> The problem is, I have a variable name "obs"; this is.. a counter
>>>>>> variable.
>>>>>> something like _n_ in SAS.
>>>>>> I do not know why it is not working.
>>>>>> I even tried a similar example in UCLA webpage:
>>>>>> http://www.ats.ucla.edu/stat/R/faq/sort.htm :it also does not seem
>>>>>>
>>> to
>>>
>>>>>> work.
>>>>>> "*sort1.hsb2 <- hsb2[order(read) , ]"*
>>>>>> Do you have any idea how to deal with this problem?? Thank you so
>>>>>>
>>> much.
>>>
>>>>>> -Hyo
>>>>>>
>>>>>>
>>>>>>> colnames(ttx1)
>>>>>>>
>>>>>> [1] "longitude 1" "longitude 2" "longitude 3" "longitude 4"
>>>>>> "longitude
>>>>>> 5"
>>>>>> [6] "longitude 6" "longitude 7" "longitude 8" "longitude 9"
>>>>>> "longitude
>>>>>> 10"
>>>>>> [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
>>>>>> "longitude
>>>>>> 15"
>>>>>> [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
>>>>>> "longitude
>>>>>> 20"
>>>>>> [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
>>>>>> "longitude
>>>>>> 25"
>>>>>> [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
>>>>>> "longitude
>>>>>> 30"
>>>>>> [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
>>>>>> "longitude
>>>>>> 35"
>>>>>> [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
>>>>>> "longitude
>>>>>> 40"
>>>>>> [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
>>>>>> "longitude
>>>>>> 45"
>>>>>> [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
>>>>>> "longitude
>>>>>> 50"
>>>>>> [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
>>>>>> "longitude
>>>>>> 55"
>>>>>> [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
>>>>>> "longitude
>>>>>> 60"
>>>>>> [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
>>>>>> "longitude
>>>>>> 65"
>>>>>> [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
>>>>>> "longitude
>>>>>> 70"
>>>>>> [71] "longitude 71" "longitude 72" "obs"
>>>>>>
>>>>>>> sortedx1=ttx1[order(-obs),]
>>>>>>>
>>>>>> Error in order(-obs) : object 'obs' not found
>>>>>>
>>>>>> [[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<http://www.r-project.org/posting-guide.html>
>>>>>>
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Jim Holtman
>>>>> Cincinnati, OH
>>>>> +1 513 646 9390
>>>>>
>>>>> What is the problem that you are trying to solve?
>>>>>
>>>>
>>>
>>> --
>>> Jim Holtman
>>> Cincinnati, OH
>>> +1 513 646 9390
>>>
>>> What is the problem that you are trying to solve?
>>>
>>>
>>
>> [[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.
>>
>>
>>
>
> ______________________________________________
> 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.
>
>
More information about the R-help
mailing list