What does it mean when the message states “the following objects are masked”?

What does it mean when the message states “the following objects are masked”?

When a message states that “the following objects are masked,” it means that those specific items or elements are hidden or obscured from view. This could be intentional, such as in a computer program where certain features are blocked or disabled for security or privacy purposes. It could also refer to physical objects that have been covered or shielded in some way. Essentially, the message is informing the recipient that the mentioned objects are not readily visible or accessible.

Interpret R Message: The following objects are masked


You may sometimes encounter the following message in R:

The following objects are masked from 'package:stats':

    filter, lag

This message appears when you load some package in R that contains functions that share names with functions that are already loaded from some other package in your current environment.

For example, suppose I load the package in R:

library(dplyr)

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

From the output we can observe:

1. The functions called filter and lag are masked from the R stats package.

  • If we use filter() or lag() in our R code, the filter() and lag() functions from dplyr will be used since it was the package loaded most recently that contains these functions.

2. The functions called intersect, setdiff, setequal, and union are masked from the R base package.

  • If we use intersect(), setdiff(), setequal(), or union() in our R code, these functions from dplyr will be used since it was the package loaded most recently that contains these functions.

How to Use Masked Functions

Suppose you would like to use the intersect() function from the base R package, but it is currently masked since there is an intersect() function that exists in the dplyr package we loaded more recently.

To explicitly use the intersect() function from base R, you can use the following syntax with double colons:

base::intersect(x, y)

In practice, you’ll most likely load several packages in your R environment at once.

To ensure that you’re using the function from some desired package, you can always type the package name with double colons in front of the function name. 

Additional Resources

Cite this article

stats writer (2024). What does it mean when the message states “the following objects are masked”?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/what-does-it-mean-when-the-message-states-the-following-objects-are-masked/

stats writer. "What does it mean when the message states “the following objects are masked”?." PSYCHOLOGICAL SCALES, 28 Jun. 2024, https://scales.arabpsychology.com/stats/what-does-it-mean-when-the-message-states-the-following-objects-are-masked/.

stats writer. "What does it mean when the message states “the following objects are masked”?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/what-does-it-mean-when-the-message-states-the-following-objects-are-masked/.

stats writer (2024) 'What does it mean when the message states “the following objects are masked”?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/what-does-it-mean-when-the-message-states-the-following-objects-are-masked/.

[1] stats writer, "What does it mean when the message states “the following objects are masked”?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. What does it mean when the message states “the following objects are masked”?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top