HI,
Possibly R FAQ: 7.31
data1New<-data1
data1New$A<- round(data1New$A,2)
data2New<- data2
data2New$A<- round(data2New$A,2)
merge(data1New,data2New,by="A")
# A B C
#1 0.0 0.9 10.0
#2 1.1 0.6 11.1
#3 1.4 0.7 11.4
#4 3.1 0.4 13.1
#5 4.4 0.8 14.4
A.K.
Hello,
Lets say we have these two data frames:
data1<-data.frame(c(1.23,1.363332,6.43209,4.230593,3.10294,5.09333,1.1,1.4,4.4,0),seq(0,by=0.1,length.out=10))
names(data1)<-c("A","B")
data2<-data.frame(seq(0,6,by=0.1),seq(10,16,by=0.1))
names(data2)<-c("A","C")
And we would like to merge only the similar values from column "A".
merge(data1,data2,by="A",all=FALSE)
we get:
A B C
1 0.0 0.9 10.0
2 1.1 0.6 11.1
3 4.4 0.8 14.4
Unfortunately, it's missing the value of 1.4 in both data.frame columns "A".
Similarly, if we instead use:
merge(data1,data2,by="A",all=TRUE)
the value of 1.4 is duplicated while 0, 1.1, and 4.4 is not.
All of the mathematical functions work as they should on the 1.4,
yet merge seems to think that the two 1.4 in the different data frames
are completely different values.
I must be going crazy, because I use the merge function all the time and I've
never run into this problem before.
Thanks.
______________________________________________
[email protected] 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.