Attach () and detach () functions in R Language

Source: Internet
Author: User

From: http://blog.sina.com.cn/s/blog_62db9b19010118bh.html

Attach () and detach ()
It is not very convenient to access objects with the $ symbol, such as accountants $ statef. A very useful job
The component of the list or data box can be directly called by their names. This call is temporary.
No need to explicitly reference the list name each time.
The attach () function can use a directory path as a parameter or a data box. Assume that the data
The lentils box has three variables: lentils $ U, lentils $ V, and lentils $ W.
> Attach (lentils)
The Data box is bound to position 2 (Position 2) of the search path. If location 1 has no variable U, V, or W,
Then U, V, and W are directly accessed in the Data box. Therefore, the following command
> U <-V + W
In fact, the variable U in the Data box is not replaced, but is replaced by the variable U in the search path location 1 workspace.
Block 4. To change the data in the data box, the simplest method is to use the $ symbol:
> Lentils $ U <-V + W
However, the new component U is invisible until the data box Binding is removed and rebound.
Remove the binding of a Data box. You can use
> Detach ()
Specifically, this command removes the binding between the search path and Location 2. At this time, U, V, and W will no longer be available
See, but you can use commands similar to lentils $ u to view these variables. If the object is in a large environment
In 2, you can directly pass the Location Value to detach to remove the binding. However, the most secure
The method is to directly specify the location by name, such as detach (lentils) and detach ("lentils ")
Note: In the latest version of R, the list and data boxes can only be located at location 2 or higher.
Secondary binding. In this way, you cannot directly assign values to the bound list and data boxes (therefore, to a certain extent
).

In fact, these two functions are the problem of locating the working path.

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.