Tidyverse library and R 3.5

Dear Friends,

I was running R.3.4.4 and updated the BioConductor package to version 3.7. Also updated R Studio to 1.1.456.

I started to get different error messages and eventually decided to update to R 3.5.1. I am now struggling with different problems. Today it looks like TIdyverse has conflicts and masks several packages that I need, for example "genefilter". I tried running my script with basic R commands to avoid Tidyverse. The end results did not make any sense compared to when I ran it with the earlier version of the EPIC package (version b2).

I have pasted the sessionInfo() below. Forgive me for not formatting this information any better.

Thank you for your help.

> library(tidyverse)
-- Attaching packages --------------------------------------- tidyverse 1.2.1 --
v ggplot2 3.0.0     v purrr   0.2.5
v tibble  1.4.2     v dplyr   0.7.6
v tidyr   0.8.1     v stringr 1.3.1
v ggplot2 3.0.0     v forcats 0.3.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x purrr::accumulate() masks foreach::accumulate()
x dplyr::collapse()   masks Biostrings::collapse(), IRanges::collapse(), nlme::collapse()
x dplyr::combine()    masks minfi::combine(), Biobase::combine(), BiocGenerics::combine()
x purrr::compact()    masks XVector::compact()
x dplyr::count()      masks matrixStats::count()
x dplyr::desc()       masks IRanges::desc()
x tidyr::expand()     masks S4Vectors::expand()
x dplyr::filter()     masks stats::filter()
x dplyr::first()      masks S4Vectors::first()
x dplyr::lag()        masks stats::lag()
x ggplot2::Position() masks BiocGenerics::Position(), base::Position()
x purrr::reduce()     masks GenomicRanges::reduce(), IRanges::reduce()
x dplyr::rename()     masks S4Vectors::rename()
x purrr::simplify()   masks DelayedArray::simplify()
x dplyr::slice()      masks XVector::slice(), IRanges::slice()
x readr::spec()       masks genefilter::spec()
x purrr::when()       masks foreach::when()
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.3.0                                       stringr_1.3.1                                      
 [3] dplyr_0.7.6                                         purrr_0.2.5                                        
 [5] tidyr_0.8.1                                         tibble_1.4.2                                       
 [7] ggplot2_3.0.0                                       tidyverse_1.2.1                                    
 [9] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0 minfi_1.26.2                                       
[11] bumphunter_1.22.0                                   locfit_1.5-9.1                                     
[13] iterators_1.0.10                                    foreach_1.4.4                                      
[15] Biostrings_2.48.0                                   XVector_0.20.0                                     
[17] SummarizedExperiment_1.10.1                         DelayedArray_0.6.3                                 
[19] matrixStats_0.54.0                                  Biobase_2.40.0                                     
[21] GenomicRanges_1.32.6                                GenomeInfoDb_1.16.0                                
[23] IRanges_2.14.10                                     S4Vectors_0.18.3                                   
[25] BiocGenerics_0.26.0                                 readr_1.1.1                                        
[27] sva_3.28.0                                          BiocParallel_1.14.2                                
[29] genefilter_1.62.0                                   mgcv_1.8-24                                        
[31] nlme_3.1-137                                        limma_3.36.2                                       

loaded via a namespace (and not attached):
 [1] colorspace_1.3-2         siggenes_1.54.0          mclust_5.4.1             base64_2.0              
 [5] rstudioapi_0.7           bit64_0.9-7              AnnotationDbi_1.42.1     lubridate_1.7.4         
 [9] xml2_1.2.0               codetools_0.2-15         splines_3.5.1            jsonlite_1.5            
[13] Rsamtools_1.32.2         broom_0.5.0              annotate_1.58.0          HDF5Array_1.8.1         
[17] compiler_3.5.1           httr_1.3.1               backports_1.1.2          assertthat_0.2.0        
[21] Matrix_1.2-14            lazyeval_0.2.1           cli_1.0.0                prettyunits_1.0.2       
[25] tools_3.5.1              bindrcpp_0.2.2           gtable_0.2.0             glue_1.3.0              
[29] GenomeInfoDbData_1.1.0   doRNG_1.7.1              Rcpp_0.12.18             cellranger_1.1.0        
[33] multtest_2.36.0          preprocessCore_1.42.0    rtracklayer_1.40.3       DelayedMatrixStats_1.2.0
[37] rvest_0.3.2              rngtools_1.3.1           XML_3.98-1.12            beanplot_1.2            
[41] zlibbioc_1.26.0          MASS_7.3-50              scales_0.5.0             hms_0.4.2               
[45] rhdf5_2.24.0             GEOquery_2.48.0          RColorBrewer_1.1-2       yaml_2.2.0              
[49] memoise_1.1.0            pkgmaker_0.27            biomaRt_2.36.1           reshape_0.8.7           
[53] stringi_1.1.7            RSQLite_2.1.1            GenomicFeatures_1.32.0   bibtex_0.4.2            
[57] rlang_0.2.1              pkgconfig_2.0.1          bitops_1.0-6             nor1mix_1.2-3           
[61] lattice_0.20-35          Rhdf5lib_1.2.1           bindr_0.1.1              GenomicAlignments_1.16.0
[65] bit_1.1-14               tidyselect_0.2.4         plyr_1.8.4               magrittr_1.5            
[69] R6_2.2.2                 DBI_1.0.0                pillar_1.3.0             haven_1.1.2             
[73] withr_2.1.2              survival_2.42-6          RCurl_1.95-4.11          modelr_0.1.2            
[77] crayon_1.3.4             progress_1.2.0           readxl_1.1.0             grid_3.5.1              
[81] data.table_1.11.4        blob_1.1.1               digest_0.6.15            xtable_1.8-2            
[85] illuminaio_0.22.0        openssl_1.0.2            munsell_0.5.0            registry_0.5            
[89] quadprog_1.5-5          

The R 3.5 update was a big one, you will need to re-install packages you use, and it's suggested to do so with install.package(<pkg_name>, dependencies = TRUE).

Does that sort your issue?

You could use the conflicted package. If you use it, everytime there is an ambiguity, it throws an error and tells you to be explicit (packagename::functionname). So this should simplify the search for the problem(s).

1 Like

The prefixer addin pairs nicely with conflicted:


Hi! Welcome!

The masking warnings can sound like some sort of intractable conflict :anguished: , but that’s not really the case. All it means is that there are packages loaded that have functions with the same names, so R needs more information from you to determine which function you are referring to. This is a normal part of R operations, and not a sign of anything going wrong.

R’s default heuristic is to give priority to the packages that were loaded last, so one approach is to make sure that you always load tidyverse first, then load the more specialized packages you need. An example:


Will have the result that when you write code using spec() R will assume you mean spec() from the genefilter package, not spec() from the readr() package.

But what if you want to use both same-named functions in your code? The answer points the way to a less fragile solution than depending on the order of your library() calls. You can always tell R explicitly which functions you mean by including the package name (namespace, in the jargon) using the same syntax you see in the tidyverse masking warning: packageName::functionName(). So genefilter::spec() will give you access to that genefilter function whether or not it’s being temporarily masked by another same-named function in a different package that was loaded later.

In practice, people tend to feel that explicitly including the namespace for all functions makes their code excessively verbose, so typically people will use the tactic only for the doppelgänger function that is rarer in their code, and let the more common one be loaded last and take masking precedence. Up to you!

One more point to remember: it’s convenient to use the tidyverse meta-package to load the default set of tidyverse packages all at once, but as your code matures you may find you aren’t actually using some of them. You can switch to loading just the ones you use individually, which will cut down on name conflicts.

Without knowing what the other error messages were/are, I’m afraid it’s hard to offer much help here. Please do feel welcome to ask about any other issues you’re encountering, but if you do so it’s probably better to start a new forum topic (you can link to this one, if you want, to provide context).


I have been installing packages along the way, but thank you for reminding me to use "dependencies = TRUE). When I update packages from the R console, it looks like "foreign" and "survival" will not update.

Thank you. I installed the conflicted package and got this message: How do I indicate which package I want?

mydata <- M.rmXY[,colnames(M.rmXY) %in% target$Barcode]

Error: %in% found in 2 packages. You must indicate which one you want with ::

  • S4Vectors::%in%
  • base::%in%

Thank you for the suggestion!

Thank you. Your explanation was very helpful.

If you want the base %in% operator, your code could look like this:

mydata <- M.rmXY[, base::`%in%`(colnames(M.rmXY), target$Barcode)]

(I'm not sure why mydata <- M.rmXY[,colnames(M.rmXY) base::`%in%` target$Barcode] is not working)

Any operator with % in the name is recognized by R as an infix operator, similar to mathematical operators such as +, - and so on. Another example of famous infix operator with % in the name is magrittr "pipe": %>%.
But when you put it into backticks as in your example, you are saying to R that this is a function that takes two arguments (in other words, it is an prefix notation as most functions are in R, e.g., mean, lapply etc). So, with the pipe, you can write

f %>% g

or you can write

`%>%`(f, g)

These 2 forms are the same.

1 Like

Thank you. Actually I don't have base::`%in%´ in the script but it seems to have jumped in there when the conflicts were happening yesterday. Today I have just called library(dplyr) and things are running without problem for the time being.