[R] Why isn't R recognising integers as numbers?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Sep 22 08:01:23 CEST 2008


Ted Byers wrote:
> Thanks Jim,
>
> Alas, it wasn't this.  Here is the output from both of your suggestions:
>
>   
>> refdata18 = read.csv("K:\\MerchantData\\RiskModel\\Capture.Week.18.csv",
>> header = TRUE,na.strings="")
>> str(refdata18)
>>     
> 'data.frame':   341 obs. of  1 variable:
>  $ X0: int  0 0 0 0 0 0 0 0 0 0 ...
>   
Ummm, is there a header line or not? If there isn't, read.csv is going 
to eat the first observation thinking it is a name (and since it is 
non-syntactic add an X in front).

The scan command looks fine, you just should have assigned it somewhere, 
x <- scan(......) and then fitdistr(x, ....)

>> scan("K:\\MerchantData\\RiskModel\\Capture.Week.18.csv", what=0L)
>>     
> Read 342 items
>   [1]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
> 0  0
>  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
> 0  0
>  [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
> 0  0
>  [76]  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
> 1  1
> [101]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
> 1  1
> [126]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
> 1  1
> [151]  1  1  1  1  1  1  1  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2 
> 2  2
> [176]  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  3  3  3  3  3  3  3  3 
> 3  3
> [201]  3  3  3  3  3  3  3  3  3  3  3  3  3  4  4  4  4  4  4  4  4  4  4 
> 4  4
> [226]  4  4  4  4  4  4  4  5  5  5  5  5  5  5  5  5  6  6  6  6  6  6  6 
> 6  6
> [251]  6  6  6  6  6  6  6  6  6  6  6  6  6  6  7  7  7  7  7  7  7  7  7 
> 7  7
> [276]  7  7  7  8  8  8  8  9  9  9  9  9  9  9  9  9 10 10 10 10 10 10 10
> 10 10
> [301] 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12
> 12 12
> [326] 12 12 12 18 18 18 18 18 18 18 18 18 18 18 18 18 18
>
>   

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list