In the use of R we almost do not open Hadley Wickham developed a few packages, the previous said Ggplot2, Reshape2, and will be talking about DPLYR
Because these packages can easily make us escape from complex data operations, the operation process is concise, and most importantly, the data results are also very concise.
First, let's take a look at the first function filter ()
Filter (. Data, ...)
The parameter is simple, only data, that is, the object to manipulate, and the other is the data operation condition.
Let's look at some simple examples
Library (DPLYR) x<-data.frame (Id=1:6, name=c ("Wang", "Zhang", "Li", "Chen", "Zhao", "song"), shuxue=c ( 89,85,68,79,96,53), yuwen=c (77,68,86,87,92,63))
Dim (x) #查看数据行列属性
[1] 6 4
X
Filter (x,name== "Zhang")
Filter (X,SHUXUE>60,YUWEN<90)
Multiple conditional filters can be made, and conditions can be separated by commas
Filter (X,SHUXUE>80|YUWEN<80)
Multi-conditional filtering, or you can use connectors & or | To connect.
In contrast, filter () is relatively simple, the use of the process is mainly to see the degree of flexibility of individuals.
Dplyr Data manipulation Data filtering (filter)