[R] Problem with numeric variable

ftorrei2@uiuc.edu ftorrei2 at uiuc.edu
Sun Aug 14 14:16:50 CEST 2005


Well, you were right. When I check with str() or summary(),
the data frame appears as having a factor for that column.
However, if I ask is.factor(C2), I get FALSE, and if I ask
is.numeric(C2) I get TRUE. This seems strange.
So I decided to reimport the dataframe, this time with NA as
undefined values, and not ?. C2 was imported as a numeric
variable, as checked with str() and is.numeric(). But I still
get the indexes and not the values when I use C2 for any
purpose, just as happened before. How can this be possible?
All the other columns in the table behave properly. 
The only difference I see between this columns ans the others
is that it contains NA values.

Thanks again,
Francisco Torreira

 
  

---- Original message ----
>Date: Sun, 14 Aug 2005 10:11:15 +0100
>From: Patrick Burns <pburns at pburns.seanet.com>  
>Subject: Re: [R] Problem with numeric variable  
>To: ftorrei2 at uiuc.edu
>
>I think your problem is that you have a factor rather
>than a numeric vector (even though you say you checked
>with 'is.numeric').  Missing values should be represented
>by 'NA' and not by '?' which is what makes me think you
>have a factor.
>
>Patrick Burns
>patrick at burns-stat.com
>+44 (0)20 8525 0696
>http://www.burns-stat.com
>(home of S Poetry and "A Guide for the Unwilling S User")
>
>ftorrei2 at uiuc.edu wrote:
>
>>Hello all,
>>
>>I posted a question some days ago without getting any answers,
>>perhaps, as one of you kindly pointed out, because the
>>question was not clearly stated. Let me reformulate it:
>>In a frame, a column named C2 represents a numeric variable
>>(checked with is.numeric(C2)). Some rows in the frame have an
>>undefined value for C2, represented in the table by a ? sign.
>>The remaining rows have numeric values with 2 decimals. For
>>example, row 10 has 43.70 for C2, while row 1 has ?. The
>>problem is that when I list C2 values (or when I try to plot
>>them, etc), these values are not the ones that appeared in the
>>table. Below are the first 3 lines of what I get when I list C2:
>>  
>>
>>>C2
>>>    
>>>
>>[1] 43 47 96 62 87 55 1 98 121 1 1 1 67 1 112 1 93 44
>>[19] 85 569 52 110 126 95 92 60 36 383 373 298 274 406 208 175
>>293 306
>>[37] 305 172 134 115 94 84 104 99 64 271 269 310 268 359 443
>>248 204 345
>>
>>These are not the correct values for C2, and I guess that they
>>are just row numbers. How can I get the correct C2 values
>>ready for analysis? Is this problem related to the fact that
>>some rows have a ? value for C2?
>>
>>Thanks in advance,
>>Francisco Torreira
>>Francisco Torreira
>>Spanish, Italian and Portuguese
>>Univ. of Illinois at Urbana-Champaign
>>707 South Mathews Aven.
>>4031 FLB
>>Urbana, IL, 61801
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>>
>>
>>
>>  
>>
>
Francisco Torreira
Spanish, Italian and Portuguese
Univ. of Illinois at Urbana-Champaign
707 South Mathews Aven.
4031 FLB
Urbana, IL, 61801




More information about the R-help mailing list