Problems and Solutions in R Language

Source: Internet
Author: User
Question 1:

Object (s) are masked from package-what does it mean?

 

Sometime when I attach a dataset, r gives me the following message/warning: "The following object (s) are masked from package: Datasets: column_name". Does anyone
Know what it means? Since it seems that the dataset was attached and I cocould manipulate the data from the dataset without problems, I am wondering what was r trying to tell me.
Sometimes, when I send a dataset, r leaves a message/warning: "The following object (s) is blocked: Dataset: column name". Who knows what this means? Because it seems to be connected to the dataset, I can manipulate the data of the dataset without any problems and I want to know what R is trying to tell me.

This has to do with R's searchpath.

When you attach () a dataset, it loads the dataset into R's current searchpath. The same occurs with packages when you use library (). This can be seen:

The r search path is required here. When you connect a dataset Using Attach (), the dataset is loaded to the r search path. When the same package occurs, you use the library (). We can see that:

 
Search ()

[1] ". globalenv" "package: Design" "package: interval Val"
[4] "package: splines" "package: hmisc" "package: chron"
[7] "package: xtable" "package: gplots" "package: gtools"
[10] "package: gmodels" "package: gdata" "package: Methods"
[13] "package: stats" "package: graphics" "package: grdevices"
[16] "package: utils" "package: datasets" "autoloads"
[19] "package: Base"
 
Or with a bit more detail:

Searchpaths ()
[1] ". globalenv"
[2] "/usr/local/lib/R/library/Design"
[3] "/usr/local/lib/R/library/interval Val"
[4] "/usr/local/lib/R/library/splines"
[5] "/usr/local/lib/R/library/hmisc"
[6] "/usr/local/lib/R/library/chron"
[7] "/usr/local/lib/R/library/xtable"
[8] "/usr/local/lib/R/library/gplots"
[9] "/usr/local/lib/R/library/gtools"
[10] "/usr/local/lib/R/library/gmodels"
[11] "/usr/local/lib/R/library/gdata"
[12] "/usr/local/lib/R/library/methods"
[13] "/usr/local/lib/R/library/stats"
[14] "/usr/local/lib/R/library/graphics"
[15] "/usr/local/lib/R/library/grdevices"

[16] "/usr/local/lib/R/library/utils"
[17] "/usr/local/lib/R/library/datasets"
[18] "autoloads"
[19] "/usr/local/lib/R/library/base"

You can see that the 'datasets' package is number 17 in the searchpath.
 

For example, if I now attach () the iris dataset (a widely used example
Dataset in R ):
 
Attach (IRIS)
Search ()
[1] ". globalenv" "Iris" "package: Design"
[4] "package: Variable Val" "package: splines" "package: hmisc"
[7] "package: chron" "package: xtable" "package: gplots"
[10] "package: gtools" "package: gmodels" "package: gdata"
[13] "package: Methods" "package: stats" "package: graphics"
[16] "package: grdevices" "package: utils" "package: datasets"
[19] "autoloads" "package: Base"

 
You can see that 'iris 'is now number 2 in the searchpath. This means that I can now access columns in the iris dataset without needing to use the typical dataframename $ columnname Syntax:

Species
[1] setosa
[7] setosa
...
 
However:

Detach (IRIS)
Species
Error: object "species" not found
Iris $ species
[1] setosa
[7] setosa
...

In your case, the warning is telling you that you have attached a data frame that presumably contains a column, whose name is 'column _ name'. If you use:

Column_name

In your r session, the object with that name in your data frame will be seen before another object with the same name that is lower in the searchpath, since your object is
Higher in the searchpath. Thus, your object is 'masking' the other.

I did not see another object called column_name in my version of the datasets package, so perhaps you have done some manipulation on those objects during your r session.

As a general comment, as has been discussed previusly in other threads, this is a potentially significant danger in the habit of using attach () and shoshould generally be avoided.

Temporary solution:

Restart rstudio.

 

Question 2:

Error: plot. New (): The image side is too large.

 

Temporary solution:

Increase the drawing window in rstudio.


Question 3: Use the pop-up dialog box to set the working path
Solution: setwd (choose. dir ("choose a suitable folder "))

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.