Merging dataframes with all.equal on numeric(float) keys?
问题 I have two data frames I want to merge based on a numeric value, however I am having trouble with floating point accuracy. Example: > df1 <- data.frame(number = 0.1 + seq(0.01,0.1,0.01), letters = letters[1:10]) > df2 <- data.frame(number = seq(0.11,0.2,0.01), LETTERS = LETTERS[1:10]) > (merged <- merge(df1, df2, by = "number", all = TRUE)) number letters LETTERS 1 0.11 a A 2 0.12 <NA> B 3 0.12 b <NA> 4 0.13 c C 5 0.14 d D 6 0.15 <NA> E 7 0.15 e <NA> 8 0.16 f F 9 0.17 g G 10 0.18 h H 11 0.19