Reputation: 551
When running the following code with a library include of rgdal on Redhat I get an incorrect result. Concretely, the inner_join seems to copy every row of the first data frame without considering the keys of the second data frame (hence just copying instead of joining).
This is a minimal running example extracted from a much bigger code within an interactive web application (r-shiny). There, my original data frames have thousands of rows. Besides the incorrect result the join will also exceed memory.
I have tried several Linux Distros and R versions. Here is the configuration where I get this bug: Red Hat Enterprise Linux Server release 7.6 (Maipo) R versions 3.5.2 (from EPEL) or 3.6.0 (compiled from scratch)
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.6 (Maipo)
Matrix products: default
BLAS: /opt/R/3.6.0/lib64/R/lib/libRblas.so
LAPACK: /opt/R/3.6.0/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=de_CH.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_CH.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=de_CH.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_1.4-4 sp_1.3-1 bit64_0.9-7 bit_1.1-14 dplyr_0.8.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 lattice_0.20-38 crayon_1.3.4 assertthat_0.2.1
[5] grid_3.6.0 R6_2.4.0 magrittr_1.5 pillar_1.4.1
[9] rlang_0.3.4 glue_1.3.1 purrr_0.3.2 compiler_3.6.0
[13] pkgconfig_2.0.2 tidyselect_0.2.5 tibble_2.1.2
The bug does not occur on Ubuntu 18.04.2 LTS, neither with R version 3.6.0 nor with R version 3.4.4.
Here is the code:
library(dplyr)
library(bit64)
library(rgdal) # Bug only when including this package
df1 <- data.frame( a=c(1,2,3), id=as.integer64(c(10,11,12)) )
df2 <- data.frame( id=as.integer64(c(13,14)), b=c(4,5) )
print( df1 )
print( df2 )
# Bug
print( nrow( df1 ) ) # 3
t <- inner_join( df1, df2, by="id" )
print( nrow( t ) ) # correct would be 0, but returns 6!
Result is:
> t
a id b
1 1 10 4
2 1 10 5
3 2 11 4
4 2 11 5
5 3 12 4
6 3 12 5
Correct would be:
> t
[1] a id b
<0 rows> (or 0-length row.names)
Considering the different results on different Linux Distros (but same R versions & libraries) I would assume the bug stems from the underlying libraries used in the RedHat Distro. I would highly appreciate any suggestions or pointers on how to resolve this.
Upvotes: 1
Views: 17