[R] data$ID -> I always get a NULL

Grześ gregorio99 at gmail.com
Mon Apr 20 17:43:41 CEST 2009


Now everything is clear for me. Thanks David! :)


David Winsemius wrote:
> 
> 
> On Apr 20, 2009, at 4:33 AM, Grześ wrote:
> 
>>
>> This is my result:
>>
>>> class(data)
>> [1] "data.frame"
>>
>>> str(data)
>> 'data.frame':	2193 obs. of  83 variables:
>> $ X.ID.                               : Factor w/ 2193 levels  
>> "'18201'",..:
>> 1 2 3 4 5 6 7 8 9 10 ...
>> $ X.kod.                       : Factor w/ 20 levels  
>> "'01'","'02'",..: 1 1
>> 1 1 1 1 1 1 1 1 ...
>> $ X.wiel.                         : int  7 7 7 7 7 7 7 8 8 8 ...
>> $ X.piech.                     : num  1 99.9 4 0.5 4 2 99.9 2 2  
>> 99.9 ...
>> $ X.rodz.                       : int  NA 2 4 NA 4 2 2 3 2 NA ...
>>
>> David Winsemius wrote:
>>>
>>>
>>> On Apr 19, 2009, at 6:45 PM, Grześ wrote:
>>>
>>>>
>>>> I have database write as .csv file.
>>>
>>> The external sorage format is not likely to be relevant. What might  
>>> be
>>> informative would be to produce the code that reads this file.
>>>>
>>>> When I want to get sth from my database I get NULL, but I know that
>>>> there is
>>>> sth!
>>>> For example:
>>>>
>>>>> data$ID
>>>> NULL
>>>>> data$kod
>>>> NULL
> 
> So the names of your columns are not "ID" and "kod" but rather "X.ID."  
> and "X.kod."
> 
> Try instead:
>   data$X.ID.
> #and:
>   data$X.kkod.     # you will need to use both the periods if your  
> column names end in periods.
> 
> 
>>>>
>>>> but command like below is always recognize by R
>>>>> data[2,3]
>>>> [1] '082'
> 
> 
> That must have been a different version of data, since data[2,3] from  
> the dataframe above should have been   the number 7  number rather  
> than a string. I would also suggest that you start naming your  
> data.frames something other than "data", since that is a reserved word  
> used by quite a few functions.
> 
> 
>>>>
>>>
>>> Tell is what happens when you enter:
>>>
>>> str(data)
>>> class(data)
>>>
>>> Perhaps the third column is not named "ID" or "kod" or the object is
>>> not a data.frame, but is rather a matrix.
>>>
>>> -- 
>>> David Winsemius
>>>>
>>>>
>>>> In my opinion this problem is also connect with my attempt to create
>>>> a tree.
>>>> I always get errors.
>>>>
>>>>> t.tree0=rpart(ID~.,t.train)
>>>> Error in eval(expr, envir, enclos) : object "ID" not found
>>>>
>>>>> t.tree0=rpart(kod~.,t.train)
>>>> Error in eval(expr, envir, enclos) : object "kod" not found
>>>>
>>>> What I should do to create my simple trees?
>>>>
> 
>>>> -- 
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/data%24ID--%3E-I-always-get-a-NULL-tp23128214p23139208.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list