r语言用attachmask怎么办
一、r语言用attachmask怎么办
展开全部使用attach(file)时,一定要配合使用detach(file),否则再此运行程序时极易出现问题,The following objects are masked 此外工作空间中不能有与file里的变量同名的全局变量存在,如果有会显示masked!

二、如何解决R语言中 the following objects are masked from data (pos=3)?
R objects that reside in other R objects can require a lot of typing to access. For example, to refer to a variable x in a dataframe df , one could type df\(x . This is no problem when the dataframe and variable names are short, but can become burdensome when longer names or repeated references are required, or objects in complicated structures must be accessed.</p><p> </p><p> The attach() function in R can be used to make objects within dataframes accessible in R with fewer keystrokes. As an example:</p><p> </p><p> ... then detach() the dataset to clean up after ourselves.</p><p> 之后,用命令 detach() 结束使用数据集。</p><p> </p><p> users are cautioned that if there is already a variable called cesd in the local workspace, issuing attach(ds) , may not mean that cesd references ds\)cesd . Name conflicts of this type are a common problem with attach() and care should be taken to avoid them.
The help page for attach() notes that attach can lead to confusion . The Google R Style Manual provides clear advice on this point, providing the following advice about attach() : The possibilities for creating errors when using attach are numerous. Avoid it.
So what options exist for those who decide to go cold turkey?
那么,有哪些应对方法呢?
(Also note the within() function, which is similar to with() , but returns a modified object.)
Some examples may be helpful:
比如下面这个例子:
In short, there’s never an actual need to use attach() , using it can lead to confusion or errors, and alternatives exists that avoid the problems. We recommend against it.
详细语法可以在R中输入 ??with 查看。
文献参考: https://www.r-bloggers.com/to-attach-or-not-attach-that-is-the-question/