In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about the convenient and small operations in R language. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.
Pipeline treatment
Pipeline processing avoids the generation of intermediate variables, which saves memory, makes the code intuitive and easy to read, and greatly simplifies the code.
In the R language, the pipe operator is "% >%" in the "dplyr" package, meaning that the result on the left is passed as an argument to the function on the right. The result on the default left is the first argument passed in the function on the right, or the only missing parameter.
Use iris dataset to introduce the use of pipeline operators.
First import the data and load the dplyr package.
When the right function has only one argument, take calculating the mean of the first column of the iris dataset as an example:
In the second way, "." Represents the location of the input parameters. In the third way, although the parentheses are removed, the function of the function remains unchanged.
When the right function has two input parameters, generate a new data box with the first two columns of the iris dataset and view the first six behavior examples:
Note that through the above three representations, the order of the first and second columns of data in the result is obtained. And if "," appears in the input parameter list of the function on the right, the corresponding position must be added "." Represents the parameter passed in to the left.
Attach () and detach () functions
When we select objects in a list or data box, we need to use the "$" symbol, but when there are many variables in the data file, it will be troublesome to use the "$" multiple times. At this time, we can use the attach () function to connect the data, so that the information in the variable can be obtained directly through the variable name. Detach () undoes the corresponding operation.
These are the convenient and small operations in R language, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.