[R] Bug in Merge?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Apr 19 00:28:01 CEST 2008


Edwin Sendjaja wrote:
> Hello,
>
>
> I find strange number in my merge data set.
>
> My first coloumn consist row numbers.
>
> -----------------------------------------------------------
> my.data:
>
>
>                     AbsTime           RelTime     PE_ID    Event      Delay
>
> 4238   1208514343.812086    107.153637  4           EKA      51620
>
> ##################################
> Host.data:
>
>
>      ID   Host
>
> 4   4    vicky.planetlab.ntua.gr
>
> ------------------------------------------------------------
>
> data<-read.table("my.data")
> mapping<-read.table("Host.data")
>
> mergeXY <- merge(data,mapping, by.x="PE_ID", by.y="ID")
>
>
> If I merge these data then i get:
>
>     "PE_ID" "AbsTime" "RelTime" "Ereignis"  "Delay" "Host"
> "2" 4 1208514343.81209 107.153637 "EndpointKeepAlive" " 
> 51620 "vicky.planetlab.ntua.gr"
>
>
> -------------------------------------------------------
>
> The first problem:
>
> Why is the row number "2" now? Where does this nummber come from?
>
>   
I don't know. Where did "Ereignis" and "EndpointKeepAlive" come from????

That is, you are paraphrasing your results instead of giving us a 
reproducible example to go on!

(And I can't reproduce it. I get a rowname of 1, whatever I try.)

 
> I think, there is a conflict between my row number from data and mapping (4238 
> and 4).
>
> The second problem:
>
> Why is my AbsTime: 1208514343.81209? It was 1208514343.812086. It is 1 digit 
> less. how can I avoid this?
>
>   
You're running out of floating point precision (the rel. error is about 
1e-16). Either user fewer digits (e.g. move the origin of time 
1208500000 units forward) or don't represent as floating point. Using 
colClasses, you can read it as a character variable and take it from 
there. One idea is to represent the integer and fractional parts separately.

-- 
   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