Library(Pryr) Returns a Message. Registered S3 Method Overwritten by 'Pryr': Method from Print.Bytes Rcpp

library(pryr) returns a message. Registered S3 method overwritten by 'pryr': method from print.bytes Rcpp

It means that both Rcpp and pryr have an S3 method (a function) called print.bytes. That is, a print method for an object of the bytes class.

Since you now loaded pryr, the function from pryr will be used, not the one from Rcpp.

This might mean that objects of class bytes will be displayed differently after loading pryr, but since it's just a print method, this is unlikely to have serious consequences.

how to suppress S3 method overwritten messages from being printed to user console

Quickly looked at the code of the package on GitHub, and to me it seems like some of those functions should be removed from NAMESPACE.

You are using @importFrom() however simply adding an "Imports:" declaration in DESCRIPTION and then calling the functions by specifying the namespace, i.e. package::function is enough. This way they would not get attached to the namespace and would not conflict with one another.


Looked a bit closer, and it seems that the issue is with the packages that you export, not your library itself. So for example simply calling library(broom.mixed) produces the conflicts. Since you export some of its import (from broomExtra) the same conflicts appear.

Seems like there is an issue about it already on their GitHub: HERE so best case would be to issue a pull request to them. Or alternatively - maybe you don't really need to export those functions in the first place.

Fatal Error (invalid active developer path ) After Upgrading R / R Studio

With many thanks to Ben, I can provide a solution to the problem. The issue is that El Capitan has a somewhat unknown xcode issue.

Open the Terminal App and enter:

xcode-select --install

It takes a few minutes to load the patch needed to run xcode. The error described above is highlighted in several instances, and this was the workaround.

I then restarted my computer and loaded the package "tkrplot" directly from the source with the code:

install.packages("tkrplot", type="source")

Once I completed these three steps, I was able to load the package "RHRV" and the associated packages "tkrplot" and "tcltk" without issue.

What does The following object is masked from 'package:xxx' mean?

The message means that both the packages have functions with the same names. In this particular case, the testthat and assertive packages contain five functions with the same name.

When two functions have the same name, which one gets called?

R will look through the search path to find functions, and will use the first one that it finds.

search()
## [1] ".GlobalEnv" "package:assertive" "package:testthat"
## [4] "tools:rstudio" "package:stats" "package:graphics"
## [7] "package:grDevices" "package:utils" "package:datasets"
## [10] "package:methods" "Autoloads" "package:base"

In this case, since assertive was loaded after testthat, it appears earlier in the search path, so the functions in that package will be used.

is_true
## function (x, .xname = get_name_in_parent(x))
## {
## x <- coerce_to(x, "logical", .xname)
## call_and_name(function(x) {
## ok <- x & !is.na(x)
## set_cause(ok, ifelse(is.na(x), "missing", "false"))
## }, x)
## }
<bytecode: 0x0000000004fc9f10>
<environment: namespace:assertive.base>

The functions in testthat are not accessible in the usual way; that is, they have been masked.

What if I want to use one of the masked functions?

You can explicitly provide a package name when you call a function, using the double colon operator, ::. For example:

testthat::is_true
## function ()
## {
## function(x) expect_true(x)
## }
## <environment: namespace:testthat>

How do I suppress the message?

If you know about the function name clash, and don't want to see it again, you can suppress the message by passing warn.conflicts = FALSE to library.

library(testthat)
library(assertive, warn.conflicts = FALSE)
# No output this time

Alternatively, suppress the message with suppressPackageStartupMessages:

library(testthat)
suppressPackageStartupMessages(library(assertive))
# Also no output

Impact of R's Startup Procedures on Function Masking

If you have altered some of R's startup configuration options (see ?Startup) you may experience different function masking behavior than you might expect. The precise order that things happen as laid out in ?Startup should solve most mysteries.

For example, the documentation there says:

Note that when the site and user profile files are sourced only the
base package is loaded, so objects in other packages need to be
referred to by e.g. utils::dump.frames or after explicitly loading the
package concerned.

Which implies that when 3rd party packages are loaded via files like .Rprofile you may see functions from those packages masked by those in default packages like stats, rather than the reverse, if you loaded the 3rd party package after R's startup procedure is complete.

How do I list all the masked functions?

First, get a character vector of all the environments on the search path. For convenience, we'll name each element of this vector with its own value.

library(dplyr)
envs <- search() %>% setNames(., .)

For each environment, get the exported functions (and other variables).

fns <- lapply(envs, ls)

Turn this into a data frame, for easy use with dplyr.

fns_by_env <- data_frame(
env = rep.int(names(fns), lengths(fns)),
fn = unlist(fns)
)

Find cases where the object appears more than once.

fns_by_env %>% 
group_by(fn) %>%
tally() %>%
filter(n > 1) %>%
inner_join(fns_by_env)

To test this, try loading some packages with known conflicts (e.g., Hmisc, AnnotationDbi).

How do I prevent name conflict bugs?

The conflicted package throws an error with a helpful error message, whenever you try to use a variable with an ambiguous name.

library(conflicted)
library(Hmisc)
units
## Error: units found in 2 packages. You must indicate which one you want with ::
## * Hmisc::units
## * base::units


Related Topics



Leave a reply



Submit