melff / memisc

Tools for Managing Survey Data, Creating Tables of Estimates and Data Summaries
https://melff.github.io/memisc
45 stars 8 forks source link

library(memisc) causes functions to print NAMESPACE cache information #47

Closed jeffreyhanson closed 4 years ago

jeffreyhanson commented 4 years ago

Hi,

It would appear that attaching both the memisc and the tibble R packages causes certain functions to print text about caches and NAMESPACES. For example, I've included a reproducible version below (tested with memisc CRAN version 0.99.25.6 and GitHub version 0.99.26.3):

# load packages
library(tibble)
library(memisc)

# create data
d <- tibble(value = seq(0, 100))

# subset data
subset_d <- subset(d, d$value < 50)
# Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
# Also defined by ‘memisc’
# Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
# Also defined by ‘memisc’

Although this text isn't a warning -- and nor is it an error message -- it could potentially cause issues from some users? One of the packages I contribute to had a similar issue a while ago, and @davidcanarte reported that they are currently experiencing this issue with the memisc R package and was looking for a fix. I believe this issue is due to defining tbl_df as a S4 class in the memisc R package (i.e. setOldClass("tbl_df")) when the tibble R package defines tbl_df as an S4 class? Therefore, a potential fix could involve (1) removing the setOldClass("tbl_df") code and (2) updating the NAMESPACE file to import the tbl_df S4 class from the tibble R package. This would also require (3) listing the tibble R package under Imports and not Enhances in the DESCRIPTION file. What do you think?

I've verified that this approach fixes the issue locally (i.e. by running the example code above on an updated fork of the memisc GitHub repository). In case this is helpful, I've submitted a PR with the proposed fix. I've bumped the version to 0.99.26.4, but please let me know if you need any additional updates to merge the PR?

melff commented 4 years ago

Fixed by commit d5ee76685e7f29c74c6dac332c89e201868630fa.

jeffreyhanson commented 4 years ago

Thanks for fixing this @melff

bixiou commented 4 years ago

For me this is still not solved with memisc 0.99.27.2.

melff commented 3 years ago

@bixiou In what way is it not solved? @jeffreyhanson's example does not lead to any messages about duplicate class definitions on my computer ...

bixiou commented 3 years ago

Well, here is what I get when I run that example on Windows 10 (I have no issue on Ubuntu 20.04):

> library(tibble)
> library(memisc)
Le chargement a nécessité le package : lattice
Le chargement a nécessité le package : MASS

Attachement du package : ‘memisc’

The following object is masked from ‘package:tibble’:

    view

The following objects are masked from ‘package:stats’:

    contr.sum, contr.treatment, contrasts

The following object is masked from ‘package:base’:

    as.array

Warning message:
le package ‘memisc’ a été compilé avec la version R 4.0.3 
> # create data
> d <- tibble(value = seq(0, 100))
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
> # subset data
> subset_d <- subset(d, d$value < 50)
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
Found more than one class "tbl_df" in cache; using the first, from namespace 'tibble'
Also defined by ‘memisc’
bixiou commented 3 years ago

I would like to re-open this issue (how do I do that?). I updated to memisc 0.99.27.3, and the problem is still not fixed. Note that the same problem occurred with another package, prioritizr, and that they fixed it: maybe the developers of memisc can apply the same kind of patch that they used there: https://github.com/prioritizr/prioritizr/issues/75

melff commented 3 years ago

Fixed in release 0.99.28.0.1 - but in a different way from @jeffreyhanson's proposal. The fix used here avoids an import dependency on the 'tibbles' package (and the resulting descent into dependency hell). (I checked this on Windows and the latest change seems to have removed the messages concerning the "tbl_df" class.

llewPromotionDocs commented 3 years ago

Still not fixed at 13/10/21. Incredibly annoying! (see https://stackoverflow.com/questions/69548961/remove-warning-message-found-more-than-one-class-tbl-df-in-cache-using-the-f/69549022?noredirect=1#comment122931339_69549022) for my attempts to fix. A clash with the most popular suite of packages on R is a stupid move.

melff commented 3 years ago
  1. I cannot fix a bug that I cannot reproduce. If I run the above code on R 4.1.1, I do not get any messages as shown above. Also, these are only informational messages, neither warnings nor errors.

  2. Please remember and respect that 'memisc' is a volunteer's work, and not a commercial product. I am sharing software that helps me very much in my own academic research, in the hope that it will help others as well. Using it does not entitle you to any kind of 'customer service'.